Reputation:
Given String:
Failed entity=/data/192a7f47-84c1-445e-a615-ff82d92e2eaa/cdata/data_0;version=2181 some lorem ipsum text.
Desired output
/data/192a7f47-84c1-445e-a615-ff82d92e2eaa/cdata/data_0;version=2181
Attempt
error.message.match(/\/data(^\s*)/)
I want to extract from /data/...
until the space after version=xxxx
please advise.
Upvotes: 0
Views: 36
Reputation: 476544
You need to place the negation (^
) within a character group ([..]
):
/\/data([^\s]*)/
Nevertheless this is a rather unsafe way to extract a url: it is possible that the word /data
is written before and after the real url. You should consider a more failsafe test.
Upvotes: 3