Regular expression

Ken Ray kray at sonsothunder.com
Wed Mar 10 12:38:04 EST 2010


Actually, Paolo, you *almost* had it right... if you change ".*" to ".*?"
you are telling the regEx to limit it to the first match. So this would
work:

if matchText(tString,"src='(.*?)'",tVal) then
  put tVal -- puts "HTTPWEB"
end if

Ken Ray
Sons of Thunder Software, Inc.
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/



On 3/10/10 9:09 AM, "Jeffrey Massung" <massung at gmail.com> wrote:

> regex should be 
> 
> if matchText(tInputString, "src='([^']*)'", tSourceMatched) is true then
> put tSourceMatched
> end if
> 
> Of course, many of the other suggestions posed by others w/o using regex are
> fine, too. Just letting you know how to do this with regex as well.
> 
> Jeff M.
> 
> 
> On Mar 10, 2010, at 5:30 AM, paolo mazza wrote:
> 
>> To me regular expressions are tricky!
>> 
>> I need to extract the string HTTPWEB from the string "xxxxxx src='HTTPWEB'
>> width='3845' height='334' xxxxx"
>> 
>> If I use the regular expression (src='.*') and the matchChunk command,
>> 
>> I get this string :   "src='HTTPWEB' width='3845' height='334'"    (see the
>> following RevTalk script)
>> 
>> 
>> Which is the regular expression to get just  the argument of the src
>> variable ( HTTPWEB in this example)?
>> 
>> Thanks a lot
>> 
>> Paolo Mazza
>> 
>> SAMPLE CODE
>> 
>> on mouseUp
>>   local TESTO,STRINGA,VAR1,VAR2
>> 
>>   put "xxxxxx src='HTTPWEB' width='3845' height='334' xxxxx" into TESTO
>> 
>>   put "(src='.*')" into STRINGA
>> 
>>   put matchText(TESTO,STRINGA) & return  into message
>> 
>>   if matchChunk(TESTO,STRINGA,VAR1,VAR2) then
>>      PUT char VAR1 to  VAR2 of TESTO into message
>>   else
>>      put "not found!" into message
>>   end if
>> 
>> end mouseUp
>> _______________________________________________
>> use-revolution mailing list
>> use-revolution at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription
>> preferences:
>> http://lists.runrev.com/mailman/listinfo/use-revolution
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution







More information about the use-livecode mailing list