Re: Regex : regular expression problem



Hi Jac,

*? means as few repeats as possible.
..*} matches all until the last }
..*?} matches all until the next } (supposing that '}' is the last char of
the pattern).

"Jac" <Jac@xxxxxxxxxxxxxxxxxxxxxxxxx> schrieb im Newsbeitrag
news:292BB614-F52A-436C-807D-2922E08CEC54@xxxxxxxxxxxxxxxx
>I found it :
>
> strTemplate = Regex.Replace(strTemplate,@"}{\\[*]\\bkmkend.*?}","&");
>
> Use of the ? : but can somebody explain this ?. What is the purpose in
> that
> expression
>
> thanks
>
> "Jac" wrote:
>
>> Hey,
>>
>> I have following string :
>>
>> blabla {\*\bkmkstart test1}{\*\bkmkend test1} line1 {\*\bkmkstart
>> test2}{\*\bkmkend test2}
>>
>> I want to change the string to the following with regex.
>> blabla &test1& line1 &test2&
>>
>> I do the following :
>> strTemplate = Regex.Replace(strTemplate,@"{\\[*]\\bkmkstart ","&");
>> strTemplate = Regex.Replace(strTemplate,@"}{\\[*]\\bkmkend.*}","&");
>>
>>
>> The result after the first replace is (correct) :
>> blabla & test1}{\*\bkmkend test1} line1 & test2}{\*\bkmkend test2}
>>
>> After the second replace :
>> blabla & test1&
>>
>> I loose the rest of the string. I think there is a problem with the
>> last }
>> in my expression.
>> I want to replace exactly this string "}{\\[*]\\bkmkend.*}" not less not
>> more. } is the last character of my string.
>> May be it is .* how gives me problems, but .* has to stop after the
>> first }
>> he see.
>>
>> How can I resolute this problem.
>> thanks for help.
>>


.



Relevant Pages

  • Re: Predicting the Future and Kolmogorov Complexity
    ... Predictability is based on the pattern itself. ... addition to the string. ... For any prediction scheme, there are computable strings that show no ... Out of this hole comes a ~2 cm blue marble followed by a red ...
    (talk.origins)
  • Re: macro for parsing text
    ... SUB will remove from any cell selected the pattern as you described (i.e. ... Dim c As Range ... Dim Temp As String ... Dim colMatches As MatchCollection ...
    (microsoft.public.excel.programming)
  • Re: macro for parsing text
    ... SUB will remove from any cell selected the pattern as you described (i.e. ... Dim c As Range ... Dim Temp As String ... Dim colMatches As MatchCollection ...
    (microsoft.public.excel.programming)
  • Re: Entropy in crystalization: up or down?
    ... such a pattern as "artifact" has exactly the same fundamental basis ... for accepting a certain type of narrow band radiosignal as artifact. ... and *that* is the reason that induction on a data string alone is worthless. ... over and over again, in radiosignals. ...
    (talk.origins)
  • Re: Model View Controller basics.
    ... Check into the command pattern: ... > And exactly this the reason for my presence here. ... you can use to write phonebook entries, address cards, etc.. ... > string fname; ...
    (comp.object)