Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It appears you want a left and right trimmed string, and a way of updating a status field for your user. These may be of interest to you:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script&gt; //option 1: just determine if the string is valid string_valid = function (str) { validity_indicator = { true:"Valid", false:"InValid", }; return validity_indicator[str.match( /\s*([^\s](:?.*[^\s])?)\s*/ ) != null]; }; // option 2: the trim and validation sort of wrapped up in one. parse_for_validity = function (str) { if ( ( result = /\s*([^\s](:?.*[^\s])?)\s*/.exec( str ) ) == null ) { return 'Incorrect'; } return result[ 1 ]; }; // then either // errmsg.innerHTML = string_valid( your_string_here ) &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;!-- and then test them out --&gt; &lt;script&gt; alert( string_valid(" ") ); // =&gt; 'Incorrect' alert( string_valid(" abc ") ); // =&gt; 'Correct' alert( parse_for_validity(" ") ); // =&gt; 'Incorrect' alert( '...' + parse_for_validity(" abc ") + '...' ); // =&gt; '...abc...' &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>With respect to the <code>/</code>, I believe you only have to concern yourself with it when you are using it within your regular expression. Having <code>/</code> in the string you are testing against is fine. If you want to test for a <code>/</code> in your regular expression, you should be able to escape it like this <code>\/</code>, as in the following expression: <code>/\//</code></p> <p>I hope this helps. I love regex! :)</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. 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