Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>According to rubular, it looks like <code>\w</code> matches all ascii letters and numbers (and underscored), but <code>\b</code> is working well for all Unicode letters. That is a little confusing. </p> <p>What you want, however, are all sequences of ASCII words. This should match them:</p> <pre><code>/\b[a-z]+\b(?:\s+[a-z]+)*\b/i </code></pre> <p>Working example: <a href="http://www.rubular.com/r/1iewl7MpJe" rel="nofollow noreferrer">http://www.rubular.com/r/1iewl7MpJe</a></p> <p>A quick explanation: </p> <ul> <li><code>\b[a-z]+\b</code> - first ASCII word.</li> <li><code>(?:\s+[a-z]+)</code> - any number of spaces and words - at least one space and one letter each time.</li> <li><code>\b</code> - to assure the last word doesn't end in the middle of another word, like <code>n</code> in <code>"con Sharp này"</code>.</li> </ul> <p>I'm not sure about getting an hash, but you can get all <a href="http://ruby-doc.org/core-1.9.3/MatchData.html" rel="nofollow noreferrer"><code>MatchData</code></a>s, similar to:<br> <a href="https://stackoverflow.com/questions/6804557/how-do-i-get-the-match-data-for-all-occurrences-of-a-ruby-regular-expression-in">How do I get the match data for all occurrences of a Ruby regular expression in a string?</a></p> <pre><code>s = "hello !@# world how a9e you" r = /\b[a-z]+\b(?:\s+[a-z]+)*\b/i matches = s.to_enum(:scan, r).map { Regexp.last_match } .map {|match| [match.to_s(), match.begin(0)]} puts matches </code></pre> <p>Here's an example on ideone: <a href="http://ideone.com/YRZE5" rel="nofollow noreferrer">http://ideone.com/YRZE5</a></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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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