0

Hi,

I have a line of text here:

Directions: Take the #8 from Meadow Park(31), and get off at Kroger East (57).

I am trying to get it to match both (31) and (57), which some other context may have different numbers, but there could be either 1 or 2 digits between the () I would like to match.

This is the regex I am using for the time being: [(\d+)], and yet, it also matches "8" in the text, which is not what I want. What should I do here to make sure that the parenthesis is included in the preg_match?

Thanks for your help.

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by pritaeas
1

Round brackets define grouping in a regex, so you need to escape them if you want to match them literally

\(\d+\)
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.