Reputation: 631
I have an url like below and wanted to use RegEx to extract segments like: Id:Reference
, Title:dfgdfg
, Status.Title:Current Status
, CreationDate:Logged
...
This is the closest pattern I got [=,][^,]*:[^,]*[,&]
but obviously the result is not as expected, any better ideas?
P.S. I'm using [^,]
to matach any characters except ,
because ,
will not exist the segment.
This is the site using for regex pattern matching. http://regexpal.com/
The URL:
http://localhost/site/=powerManagement.power&query=_Allpowers&attributes=Id:Reference,Title:dfgdfg,Status.Title:Current Status,CreationDate:Logged,RaiseUser.Title:标题,_MinutesToBreach&sort_by=CreationDate"
Thanks,
Upvotes: 0
Views: 37
Reputation: 93191
You haven't specified what programming language you use. But almost all with support this:
([\p{L}\.]+):([\p{L}\.]+)
\p{L}
matches a Unicode character in any language, provided that your regex engine support Unicode. RegEx 101.
You can extract the matches via capturing groups if you want.
Upvotes: 2
Reputation: 354
In python:
import re
matchobj = re.match("^.*Id:(.*?),Title:(.*?),.*$", url, )
Id = matchobj.group(1)
Title = matchobj.group(2)
Upvotes: -1