Note that there are some explanatory texts on larger screens.

plurals
  1. POjavascript regex examples - extract until character appears?
    primarykey
    data
    text
    <p>I have a text like this.</p> <pre><code>Mr John Smith , Mr James Smith +(21)-(21)-12345678, 12345678, 12345678 +(21)-12345678, 12345678, 12345678 SomeTextHereAlso +(21)-(22)-12345678 www.somewebaddress.co.uk Some Title, Some Place , Some Town,Some Suburb,  City - 100000 </code></pre> <p>I want to extract each of these strings using regex in javascript. I found some examples and this morning they worked. Now I don't know why they don't work any more.</p> <p>To extract</p> <pre><code>Mr John Smith , Mr James Smith </code></pre> <p>I used this.</p> <pre><code>/\S(.*)\+/ and /\S(.*?)\+/ </code></pre> <p>This didn't work. I can't figure out why.</p> <p>To extract this</p> <pre><code>+(21)-(21)-12345678, 12345678, 12345678 +(21)-12345678, 12345678, 12345678 SomeTextHereAlso +(21)-(22)-12345678 </code></pre> <p>I used this.</p> <pre><code>/\+(.*)(?=www.)/ </code></pre> <p>This did work.</p> <p>And for url I used</p> <pre><code>/www(.*?)(?=\s\s)/ </code></pre> <p>And this works too. </p> <p>The only problem is the first example that should extract all the characters until the first + but it extracts all the characters until the last +.</p> <p>I checked on <a href="http://gskinner.com/RegExr/?2tr5t" rel="nofollow">http://gskinner.com/RegExr/?2tr5t</a> and the examples I showed here work. Are there any more similar examples that could help me since I looked into the code and didn't find any error.</p> <p>If regex is fine then how can I use IndexOf() method for this example to extract what I want?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload