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. 2 1498
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.
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" <Ja*@discussions.microsoft.com> schrieb im Newsbeitrag
news:29**********************************@microsof t.com... 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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: aevans1108 |
last post by:
expanding this message to microsoft.public.dotnet.xml
Greetings
Please direct me to the right group if this is an inappropriate place
to post this question. Thanks.
I want to format a...
|
by: alphatan |
last post by:
Is there relative source or document for this purpose?
I've searched the index of "Mastering Regular Expression", but cannot
get the useful information for C.
Thanks in advanced.
--
Learning...
|
by: Dave |
last post by:
I'm struggling with something that should be fairly simple. I just don't
know the regext syntax very well, unfortunately.
I'd like to parse words out of what is basically a boolean search...
|
by: |
last post by:
Here is an interesting one. Running asp.net 2.0 beta 2. I have a regular
expression used in a regex validator that works on the client side in
Firefox but not in IE. Any ideas? IE always reports...
|
by: clintonG |
last post by:
I'm using an .aspx tool I found at but as nice as the interface is I
think I need to consider using others. Some can generate C# I understand.
Your preferences please...
<%= Clinton Gallagher
...
|
by: JebBushell |
last post by:
I see signs that the ASP.NET regular expression validator has a different
instruction set that the Find utility in VS 2003.
I am trying to use the VS2003 regular expression Find tool to test...
|
by: Mark |
last post by:
I must create a routine that finds tokens in small, arbitrary VB code
snippets. For example, it might have to find all occurrences of
{Formula}
I was thinking that using regular expressions...
|
by: MooMaster |
last post by:
I'm trying to develop a little script that does some string
manipulation. I have some few hundred strings that currently look like
this:
cond(a,b,c)
and I want them to look like this:
...
|
by: Nightcrawler |
last post by:
Hi all,
I am trying to use regular expressions to parse out mp3 titles into
three different groups (artist, title and remix). I currently have
three ways to name a mp3 file:
Artist - Title ...
|
by: ommail |
last post by:
Hi
I wonder if regular expressions are in general sower than using
classes like String and
Char when used for validating/parsing text data?
I've done some simple test (using IsMatch()) method...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |