Help for writing a regex

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
sapoczka
Forum Newbie
Posts: 1
Joined: Mon Apr 07, 2014 5:41 am

Help for writing a regex

Post by sapoczka »

Hello everybody...

I'm completely new in regex using but I need help for creating one that will recognized that type:

{(1,4),(2,3),(3,8),(6,7)},{(1,8),(2,7),(3,6),(4,5)}

Help me please!!!

Thanks
User avatar
Celauran
Moderator
Posts: 6425
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Help for writing a regex

Post by Celauran »

Ugly, but this'll do it.

Code: Select all

\{(\(\d,\d\),?){4}\},?{2}
There's probably a more elegant regex you can come up with. Take a look at Rubular.
regexer
Forum Newbie
Posts: 4
Joined: Sat Dec 20, 2014 6:38 pm

Re: Help for writing a regex

Post by regexer »

Code: Select all

^((\{(\(\d,\d\),?)+(?<!,)\},?)+)$
http://www.regex-builder.com/ online regular expression composer based on text analysis
Post Reply