Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #19527

Re: Help creating 'simple' regex

From "Joey@still_Learning.invalid" <Joey@still_Learning.invalid>
Newsgroups comp.lang.javascript
Subject Re: Help creating 'simple' regex
Date 2013-04-29 01:40 -0700
Message-ID <abcsn8pg27625clds8tf9cs8vpb0gucq4v@4ax.com> (permalink)
References (1 earlier) <gt3on8tkhr5iu14im8cprl1jtre1e4pm7u@4ax.com> <klhcb9$vdr$1@news.albasani.net> <27oon89p058st28cgicdg93c3sdcoghpth@4ax.com> <XnsA1B05F1BB33B3eejj99@194.109.133.133> <4vmpn8lv41nhapq42a8q1fapqdh4qqr62h@4ax.com>

Show all headers | View raw


Joey@still_Learning.invalid wrote:
>Joey@still_Learning.invalid wrote:
>>Evertjan. wrote:
>>>Joey@still_Learning.invalid wrote on 28 apr 2013 in comp.lang.javascript:
>>>
>>>>>  var found = testString.indexOf("testing") > -1;

>>>> I can't use indexOf(), because there are spaces before, after and withing
>>>> the string.
>>>
>>>Invalid argument.
>>
>>I don't agree. If the use inputs nothing, indexOf() will kick back a true,
>>when indeed the input is false.

I was wrong! Thanks...you got me thinking (for a change it seems) 
>
>Additionally...were I to use indexOf() and the user entered test instead
>of testing, I'd see a incorrect true response. That's what drove me to try
>a regular expression to find a perfect match.
>
>I'm very interested in why you believe my argument to be invalid. (Please)

The answer is so simple, I'm embarrassed having asked the question. :-)

firstString = document.form.elements["firstString"].value; //'Mary Smith'
testString = document.form.elements["testString"].value;
//Mary Smith-00003.img

adjName = testString.indexOf("-00");
endName = imageName0.substr(0,adjName);
testNames = endName.indexOf(firstString);
if (testNames != -1 && firstString == endName)  {
	alert("Identical")
}

From here, it's a simple task of identifying why the names are not
identical and alerting the user. With appropriate validation on
firstString input, I can filter out erroneous firstString inputs, e.g.,
double spaces. I have no control on validating testString, except the
knowledge its form is 'userinput-nnnnnm.img.'

The word doh! comes to my mind. 

Thank you.
-- 
Joey

Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Help creating regex "Joey@still_Learning.invalid" <Joey@still_Learning.invalid> - 2013-03-20 11:47 -0700
  Re: Help creating regex Danny <dann90038@gmail.com> - 2013-03-20 12:08 -0700
    Re: Help creating regex "Joey@still_Learning.invalid" <Joey@still_Learning.invalid> - 2013-03-20 12:18 -0700
  Re: Help creating regex Jim T. <x@y.z> - 2013-03-20 15:11 -0500
    Re: Help creating regex "Joey@still_Learning.invalid" <Joey@still_Learning.invalid> - 2013-03-20 12:19 -0700
      Re: Help creating regex Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid> - 2013-03-21 20:20 +0000
  Help creating 'simple' regex "Joey@still_Learning.invalid" <Joey@still_Learning.invalid> - 2013-04-27 10:56 -0700
    Re: Help creating 'simple' regex JJ <duh@nah.meh> - 2013-04-28 02:27 +0700
      Re: Help creating 'simple' regex "Joey@still_Learning.invalid" <Joey@still_Learning.invalid> - 2013-04-27 16:39 -0700
      Re: Help creating 'simple' regex "Joey@still_Learning.invalid" <Joey@still_Learning.invalid> - 2013-04-28 09:36 -0700
        Re: Help creating 'simple' regex "Joey@still_Learning.invalid" <Joey@still_Learning.invalid> - 2013-04-29 01:41 -0700
    Re: Help creating 'simple' regex Stefan Weiss <krewecherl@gmail.com> - 2013-04-27 22:27 +0200
      Re: Help creating 'simple' regex Stefan Weiss <krewecherl@gmail.com> - 2013-04-27 22:34 +0200
      Re: Help creating 'simple' regex "Joey@still_Learning.invalid" <Joey@still_Learning.invalid> - 2013-04-27 16:39 -0700
        Re: Help creating 'simple' regex "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-04-28 09:20 +0200
          Re: Help creating 'simple' regex "Joey@still_Learning.invalid" <Joey@still_Learning.invalid> - 2013-04-28 01:22 -0700
            Re: Help creating 'simple' regex Stefan Weiss <krewecherl@gmail.com> - 2013-04-28 11:32 +0200
              Re: Help creating 'simple' regex "Joey@still_Learning.invalid" <Joey@still_Learning.invalid> - 2013-04-28 09:53 -0700
                Re: Help creating 'simple' regex Stefan Weiss <krewecherl@gmail.com> - 2013-04-28 19:41 +0200
                Re: Help creating 'simple' regex "Joey@still_Learning.invalid" <Joey@still_Learning.invalid> - 2013-04-28 23:51 -0700
            Re: Help creating 'simple' regex "Joey@still_Learning.invalid" <Joey@still_Learning.invalid> - 2013-04-28 09:14 -0700
            Re: Help creating 'simple' regex "Joey@still_Learning.invalid" <Joey@still_Learning.invalid> - 2013-04-29 01:40 -0700

csiph-web