A. M. Mérida
A. M. Mérida

Reputation: 2618

Regex parenthesis

I problem in Regex, the URL no with match:

Sound/ranzor%20S001/sound,ranzor%20S001,245--40%20ZR20%20(95Y),TL,AMR

Expression of Regex is:

((.+?)/(.+?)/.+?,.+?,(\d+)--(\d{1,3})%\d{2}R(\d{1,3})%\d{2}|(\d{1,3}\w).*)

The problem is (95Y).

Thanks.

The solution:

((.+?)/(.+?)/.+?,.+?,(\d+)--(\d{1,})%\d{2}.?.?(\d{1,})%\d{2}\((\d{1,})(\w{1}).*)

The solution is escape "(".

Upvotes: 0

Views: 124

Answers (2)

Sina Iravanian
Sina Iravanian

Reputation: 16286

In the middle R should be changed to ZR. Also I don't understand why you used the OR (|) Pattern, I removed it, and put parentheses around:

(.+?)/(.+?)/.+?,.+?,(\d+)--(\d{1,3})%\d{2}ZR(\d{1,3})%\d{2}\((\d{1,3}\w)\).*

Upvotes: 2

Raheel Hasan
Raheel Hasan

Reputation: 6023

try this regex:

/((.+?)/(.+?)/.+?,.+?,(\d+)--(\d{1,3})\%\d{2}R(\d{1,3})\%\d{2}|\(\d{1,3}\w\).*)/

You need to escape %, ( and ). To do so, add backslash before them

Upvotes: 2

Related Questions