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?
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.
You can also try this pattern:
>[^\.]+\.<
Independent of any specific character (other than last dot), just in the same way as yours.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.