Showing posts with label regex. Show all posts
Showing posts with label regex. Show all posts

Thursday, July 19, 2007

Regex with Named Groups

Suppose you want to remove a middle name from name you can use “replace” method in your favorite language/editor in this way..
You Regulare Expression: (?(\w+))\s*(?(\w+))\s*(?(\w+))\s*

Replace with: ${ FirstName } ${ LastName }

Some days before when I needed help about this, googling didn’t help much. If you come across any good link about this, don’t forget to put a comment here.

(This may be a bad example but I am using it just for simplicity and the sole objective of this blog is to understand 'named group' or 'variable')

[Updates]
Tutorial Link:
http://www.regular-expressions.info/named.html