Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Regular Expressions in <a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm" rel="nofollow noreferrer">ECMAScript</a> implementations are IMHO best explained at the <a href="https://developer.mozilla.org/" rel="nofollow noreferrer">Mozilla Developer Network (formerly, Mozilla Developer Center)</a> in the <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/RegExp" rel="nofollow noreferrer"><code>RegExp</code> article</a> of the <a href="https://developer.mozilla.org/en/JavaScript/Reference/" rel="nofollow noreferrer">JavaScript Language Reference</a> pp.</p> <p>However, as noted, the previous answers do not take <em>non-English</em> letters into account, such as umlauts and accented letters. In order not to remove those letters from the string, you have to exclude them from the character range like so:</p> <pre><code>var s = "Victor 1 jagt 2 zwölf 3 Boxkämpfer 4 quer 5 über 6 den 7 Sylter 8 Deich"; s = s.replace(/[^a-zäöüß]+/gi, ""); </code></pre> <p>This approach quickly becomes tedious and hard to maintain, especially if <em>several</em> natural languages need to be considered (and even in proper English there are foreign words like "<em>déjà vu</em>" and "<em>fiancé</em>"). </p> <p>Therefore, among other <a href="http://www.pcre.org/" rel="nofollow noreferrer">PCRE</a> features, <a href="http://pointedears.de/websvn/filedetails.php?repname=JSX&amp;path=%2Ftrunk%2Fregexp.js" rel="nofollow noreferrer">JSX:regexp.js</a> lets you use Regular Expressions that can use Unicode property classes, through the <a href="http://unicode.org/ucd/" rel="nofollow noreferrer">Unicode Character Database (UCD)</a>.</p> <p>You would then write¹</p> <pre><code>var s = "Victor 1 jagt 2 zwölf 3 Boxkämpfer 4 quer 5 über 6 den 7 Sylter 8 Deich"; var rxNotLetter = new jsx.regexp.RegExp("\\P{Ll}+", "gi"); s = s.replace(rxNotLetter, ""); </code></pre> <p>or</p> <pre><code>var s = "El 1 veloz 2 murciélago 3 hindú 4 comía 5 feliz 6 cardillo 7 y 8 kiwi. La cigüeña tocaba el saxofón detrás del palenque de paja" + " – Съешь 1 же 2 ещё 3 этих 4 мягких 5 французских 6 булок, да 7 выпей 8 чаю."; var rxNotLetterOrWhitespace = new jsx.regexp.RegExp("[^\\p{Ll}\\p{Lu}\\s]+", "g"); s = s.replace(rxNotLetterOrWhitespace, ""); </code></pre> <p>to reduce dependency on the uppercase/lowercase quirks of implementations (and be more extensible), for a <code>RegExp</code> that excludes all non-letter Unicode characters (and white-space in the second example).</p> <p><a href="http://PointedEars.de/scripts/test/regexp" rel="nofollow noreferrer">Testcase</a></p> <p>Be sure to provide a version of the Unicode Character Database as well, because it is large, in flux, and therefore not built into regexp.js (JSX contains a verbose text and compacted script version of the UCD; both can be used, and the latter is preferred, by regexp.js). Note that <a href="http://ecma-international.org/ecma-262/5.1/#sec-2" rel="nofollow noreferrer">a conforming ECMAScript implementation does not need to support characters beyond the Basic Multilingual Plane (U+0000 to U+FFFF)</a>, so <code>jsx.regexp.RegExp</code> currently cannot support those even though they are in the UCD. See the documentation in the source code for details.</p> <p>¹ <a href="http://en.wikipedia.org/wiki/Pangram" rel="nofollow noreferrer">Pangrams</a> from <a href="http://wikipedia.org/" rel="nofollow noreferrer">Wikipedia</a>, the free encyclopedia.</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. 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.
    3. 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