Reputation: 19847
I have the following being stored in a variable
>a.<
>b.<
>c.<
but there's a bunch of other stuff around it, what regex would I use to match
>(.*).<
where (.*) is any single letter?
Upvotes: 0
Views: 54
Reputation: 1881
Try using this regular expression: \>([a-zA-Z])\.\<
The dot is a control character that must be escaped. The []
specifies a range for a single character.
EDIT:
These characters needs to be escaped: . \ + * ? [ ^ ] $ ( ) { } = ! < > | : -
according to http://php.net/manual/en/function.preg-quote.php. I have updated my answer to reflect that.
Upvotes: 3
Reputation: 11233
You can also try this pattern:
>[^\.]+\.<
Independent of any specific character (other than last dot), just in the same way as yours.
Upvotes: 1