Re: Regex : regular expression problem
- From: "Christof Nordiek" <cn@xxxxxxxxx>
- Date: Fri, 20 May 2005 14:49:15 +0200
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.
>>
.
- References:
- Regex : regular expression problem
- From: Jac
- RE: Regex : regular expression problem
- From: Jac
- Regex : regular expression problem
- Prev by Date: Close Win Form
- Next by Date: Re: GC, Windows or Design problem?
- Previous by thread: RE: Regex : regular expression problem
- Next by thread: Anchor links in Control
- Index(es):
Relevant Pages
|