Regex, replace and quantifiers

  • Thread starter Thread starter MaxMax
  • Start date Start date
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
 
* 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
 
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.
 
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.
======================================
 
Back
Top