user7014993
user7014993

Reputation:

match any character until the space

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

Answers (2)

Johan Morales
Johan Morales

Reputation: 149

Try this:

/^\/data+[-\/;\w=]+/g

Upvotes: 0

willeM_ Van Onsem
willeM_ Van Onsem

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

Related Questions