Hi I need an ICU regex that I think it is pretty basic but I don’t know how to build it right. The regex should match strings like:
font-size: 9pt;
font-size: 15pt;
font-size:2pt;
font-size:22pt;
I’m trying to make something like this but it doesn’t work:
regex = \bfont\-size: [0-9]{3}pt;\b
I’m really new to regex so I’m not sure what am I doing wrong here. Any help is much appreciated.
P.S.: Does anyone know a good resource to get the hang of this fast?
font\-size\: ?[0-9]{1,3}pt\;Should do the trick. Essentially, escape all non-alphanumeric characters (just to be on the safe side). Also,
{1,3}means repeating 0-9 from one to three times, instead of always three times.Edit:
Updated the above regex. The trailing
\bwas removed, and the space before the number was made optional using?.Python demonstration: