Regex, replace and quantifiers

M

MaxMax

Is it possible to modify an expression with quantifiers in this way:

ABCD to A!B!C!D!

the pattern of the first expression would be something like:
[A-Z]*

but if I use this:

But I don't know how make the replace string (and I'm not even sure it's
possible to do it only with regex)

--- bye
 
J

Jesse Houwing

* MaxMax wrote, On 18-6-2007 14:17:
Is it possible to modify an expression with quantifiers in this way:

ABCD to A!B!C!D!

the pattern of the first expression would be something like:
[A-Z]*

but if I use this:

But I don't know how make the replace string (and I'm not even sure it's
possible to do it only with regex)

--- bye

If you just want a ! after every [A-Z] then it's quite easy:

Input pattern: [A-Z]
Replace pattern: $0!

Jesse
 
W

Walter Wang [MSFT]

Hi MaxMax,

What Jesse suggested is using the substitution notation to replace the
matched string using $0. You can also use $1, $2, ... etc to replace a
group if you're capturing the part of the match in a group.

#Substitutions
http://msdn2.microsoft.com/en-us/library/ewy2t5e0.aspx


#Grouping Constructs
http://msdn2.microsoft.com/en-us/library/bs2twtah.aspx


Hope this helps.


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
W

Walter Wang [MSFT]

Hi MaxMax,

Feel free to let us know if there's anything unclear. Thanks.


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
======================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Regex in C# 4
RegEx Format Help 4
Newbie question about Regex 8
Obfuscate Email 1
Regex help 1
regex replace question 1
regex question 3
Obfuscate 4

Top