Page 1 of 1

Simple placeholder extraction regex

Posted: Tue Feb 09, 2010 8:00 am
by alex.barylski
I have the following:

Code: Select all

'#\{\%MANUAL_([0-9]+)\%\}#'
I need to extract placeholders of the type {%MANUAL_#####%}

Where ##### is any number between 1 and the limit of an integer, so it should be arbitrary, but always numbers.

The above regex is pretty simple but I figured I would post something incase I missed a caveat.

Cheers,
Alex

Re: Simple placeholder extraction regex

Posted: Tue Feb 09, 2010 8:09 am
by prometheuzz
Nope, you haven't missed anything. It'll work as you expect it to.

The only thing is that you escape characters that don't need escaping ('%' and '}' are no meta characters), although it does not hurt to do so.

This will do the same:

Code: Select all

'#\{%MANUAL_([0-9]+)%}#'