PDA

View Full Version : [SOLVED] Regex



epicoder
June 16th, 2010, 09:17 PM
How do I make a regex that matches a character, then any amount of characters, then another character?

in bash, I would use:

a*b

Which would match anything starting with a and ending with b, with any number of any characters in between them. How would I do this in regex?

DanielWaterworth
June 16th, 2010, 09:20 PM
a.*b

amauk
June 16th, 2010, 09:20 PM
a.*b

dot (in this instance) means any character
and that's used with the asterisk for "any number of characters

Bachstelze
June 16th, 2010, 09:21 PM
a.*b

. means "any character" and * means "the last character repeated any number of times".


man 7 regex

epicoder
June 16th, 2010, 09:27 PM
Thanks, guys!

You know, now that I see it, I wonder why I didn't get that in the first place after googling regex. It seems kinda obvious. Oh well.