سؤال

I need a regular expression that matches the shortest string between "$" and "|$"

Example test string:

'bla bla$bla bla $bla bla|$bla bla bla'

regular expression:

/\$(.*?)\|\$/

i get

'bla bla $bla bla'

but i need bla bla

Has anyone an idea how to accomplish this?

هل كانت مفيدة؟

المحلول

Use a negated character class:

\$([^$]*)\|\$
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top