Re: [Nolug] test

From: Petri Laihonen <pietu_at_weblizards.net>
Date: Wed, 10 Jun 2009 22:51:24 -0500
Message-ID: <4A307F3C.9030303@weblizards.net>

I don't know whether or not the % should be replaced by ' - '.
Most likely, and in most cases this would be true, but there could also
be space, or something else. If I could simply just replace the '%' with
'-', I would not have any problems. then I could just do simply
if (stripos('ABC-A706','model-abc-a706/ software version 0.3 /sumptin
else') !== FALSE); // match
if (stripos('ABC-A706','model-abc-h706/ software version 0.3 /sumptin
else') !== FALSE); // no match
Note! Strangely '=== TRUE' does not seem to be working as well as '!==
FALSE'

Also, I think [abc|ABC] would limit the characters into 'abc' or 'ABC'.
In real life they are definitely something else, and will vary.

I tried to test the strings and minor modifications here,
http://www.regextester.com/.
Apparently I don't know how to use it as nothing appears to be matching.....

Well... Gotta whip up the PHP test script ... :-)

Petri

Louis.Ross@selu.edu wrote:
> why not literally use the '-' in between?
> /^(.+)[abc|ABC]-[a|A]706(.*)$/
> /^(.+)[abc|ABC]\-[a|A]706(.*)$/
>
> (I'm not sure the - may have to be escaped by a \slash, try it both ways)
> this also says lower or uppercase "abc" and lower or uppercase 'a'
> Guy
> On Wednesday, June 10, 2009 10:27 PM, Petri Laihonen wrote:
>
>> Date: Wed, 10 Jun 2009 22:27:56 -0500
>> From: Petri Laihonen
>> To: nolug@nolug.org
>> cc:
>> Subject: Re: [Nolug] test
>>
>> OK... Trying to learn something here.... I've read today from here and
>> there, a dot is the "universal" match-all, though should be used cautiously.
>> Some of my attempts to form the regex expression involved square
>> brackets []... apparently those are not needed.
>>
>> Now if I want to match with 2 parts of the original string.....
>>
>> How does this look like?
>> /^(.+)abc(.)a706(.+)$/
>>
>> Petri
>>
>>
>>
>> Louis.Ross@selu.edu wrote:
>>
>>> try
>>> /^(.+)a706(.+)$/
>>> starts with one or more of any character followed by literally 'a706'
>>> or
>>>
>>>
>>> preg_match('/^(.+)a706\/(.+)\/(.+)$/',"$test_string");
>>>
>>> starts with one or more of any character followed by literally 'a706' and then /, more chars, /,more chars at the end of the string
>>>
>>>
>>> returns boolean true if $test_string contains 'a706' in the specified position
>>> also
>>> $1 == 'model-abc-';
>>> $2 == 'software version 0.3';
>>> $3 == 'sumptin else';
>>> will return true
>>>
>>> That's all I got, there's more ways to skin that cat for sure.
>>>
>>> Guy Ross
>>>
>>>
>>>
>>>
>>> On Wednesday, June 10, 2009 9:16 PM, Chris Jones wrote:
>>>
>>>
>>>> Date: Wed, 10 Jun 2009 21:16:39 -0500
>>>> From: Chris Jones
>>>> To: nolug@nolug.org
>>>> cc:
>>>> Subject: Re: [Nolug] test
>>>>
>>>> Generally, regex's are more picky than that. A isn't going to match
>>>> a, plus all those characters before and after the regex have to be
>>>> matched wtih a wildcard. It really depends on what you're trying to
>>>> do that determines the right approach.
>>>>
>>>> On Wed, Jun 10, 2009 at 7:06 PM, Petri Laihonen<pietu@weblizards.net> wrote:
>>>>
>>>>
>>>>> Tried to send again, but for some reason this post does not appear in the
>>>>> nolug list.
>>>>> Therefore, since my reply to "test" appeared, perhaps this one does too.
>>>>>
>>>>>
>>>>> Orig Subject: Regex help needed
>>>>>
>>>>> Do we have any regex geniuses on the wire?
>>>>>
>>>>> I've heard regular expressions are powerful thing....... I agree ....they
>>>>> are very powerful driving you nuts trying to figure them out.....
>>>>>
>>>>> I'm trying to match 2 strings together.... (Will use in a PHP environment)
>>>>> String 1: "ABC%A706" (Where % is a wildcard, thus should match to any
>>>>> character)
>>>>> String 2: "
>>>>>
>>>>>
>>> a706/ software version 0.3 /sumptin else"
>>>
>>>
>>>>> String 3: "model-abc-h706/ software version 0.3 /sumptin else"
>>>>>
>>>>>
>>>>> With the above strings, 1 and 2 would be match, but 1 and 3 are not.
>>>>>
>>>>> In other words, anything before, on the % sign, and after the string 1
>>>>> is OK. As long as portions "abc" and "a706" are found from the longer
>>>>> string with only one character, ....any character in between them.
>>>>>
>>>>> Any hints?
>>>>>
>>>>> Petri
>>>>>
>>>>>
>>>>>
>>>>> Joey Kelly wrote:
>>>>>
>>>>>
>>>>> --
>>>>> This message has been scanned for viruses and
>>>>> dangerous content by MailScanner, and is
>>>>> believed to be clean.
>>>>>
>>>>> ___________________
>>>>> Nolug mailing list
>>>>> nolug@nolug.org
>>>>>
>>>>>
>>>>>
>>>> --
>>>> Chris Jones
>>>> http://www.doomsdaytechnologies.com
>>>> ___________________
>>>> Nolug mailing list
>>>> nolug@nolug.org
>>>>
>>>>
>>>
>>> ___________________
>>> Nolug mailing list
>>> nolug@nolug.org
>>>
>>>
>>>
>> --
>> This message has been scanned for viruses and
>> dangerous content by MailScanner, and is
>> believed to be clean.
>>
>> ___________________
>> Nolug mailing list
>> nolug@nolug.org
>>
>
>
>
> ___________________
> Nolug mailing list
> nolug@nolug.org
>
>

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
___________________
Nolug mailing list
nolug@nolug.org
Received on 06/10/09

This archive was generated by hypermail 2.2.0 : 08/06/09 EDT