How can I write this POSIX regexp like Perl regexp? <b>\$([0-9]+\.[0-9]{2})-{0,1}\${0,1}([0-9]+\.[0-9]{2}){0,1}</b>
Well it would help for you to tell us what you're testing for. Perl regexp could probably work the same way except changing: /^ add that at beginning $/ and that at the end.
I am testing for two kinds of string: <b>$1.45-$14.67</b> <b>$1.45</b> first digit is long at least 1 character and the second is exactly 2 chars
I don't think the start/end markers are needed, he probably wants to match this code segment in a HTML page. This should help (I also simplified some parts, e.g. changing "{0,1}" to "?"): my $html = "your HTML"; my $price1 = 0.0; my $price2 = 0.0; if ($html =~ m/\<b>\$([0-9]+\.[0-9]{2})(-\$([0-9]+\.[0-9]{2}))?\</b>/) { $price1 = $1; $price2 = $3; # need a defined() check? } Code (markup):