Sign in to follow this  
Followers 0
MikeP

[SOLVED] Syntax problem. Regexp with "

8 posts in this topic

#1 ·  Posted (edited)

Hi. This might be easy but I can't seem to find the answer.

I'm parsing a file to get such strings : <TD><blhalbhal><A HREF="subdir/blahblah.htm"> </TD>

Then I need to use StringRegExp to search for the HREF="subdir/ characters. My problem is I can't write this :

$test = StringRegExp($string, "A HREF="subdir/", 0)

because the " after the = is finishing the parameter... I don't know if I'm clear or not but If you understood and know how to do this I'd be glad that you'd show me as I'm clueless till now....

Thanks !

Edited by MikeP

Share this post


Link to post
Share on other sites



Not sure I understand what you want accomplish but is this what you mean?

$string = '<TD><blhalbhal><A HREF="subdir/blahblah.htm"> </TD>'
$array = StringRegExp($string, 'A HREF="(.*?)"', 3)
for $i = 0 to UBound($array) - 1
    msgbox(0, "RegExp Test with Option 3 - " & $i, $array[$i])
Next

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

well I think I asked too fast. I found the answer. To search for " without having to type it (since it would be wrong syntaxically speaking..because it ends the string to test) I had to use the ASCII code which is 042 for the " .. and in regexps it's written like this \### ascii code in octal :) thus :

wrong :

$test = StringRegExp($string, "A HREF="subdir/", 0)oÝ÷ Ú¸ Ö®¶­sbb33c·FW7BÒ7G&æu&VtWb33c·7G&ærÂgV÷C´$TcÒb3#²b3C³C'7V&F"ògV÷C²Â
Edited by MikeP

Share this post


Link to post
Share on other sites

$test = StringRegExp($string, 'A HREF="subdir/"')
If ($test) Then MsgBox(64, "Info", "Sub Directory Exists.")


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

$test = StringRegExp($string, 'A HREF="subdir/"')
If ($test) Then MsgBox(64, "Info", "Sub Directory Exists.")
well for that case your solution works but I also had such strings to test :

java script:function("blabh"),'test','200')

so .. ASCII is mandatory here :) since there are " and ' in the string to test

or it would come to be quite awful syntax with such thing like :

StringRegExp($string, 'java script:function("blahblah"),'&"'test','200')")

horrible :)

Edited by MikeP

Share this post


Link to post
Share on other sites

well for that case your solution works but I also had such strings to test :

java script:function("blabh"),'test','200')

so .. ASCII is mandatory here :) since there are " and ' in the string to test

Since we have the ability to concatenate strings, the ASCII is not mandatory, but if it is your preference that is fine as well :) .

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

well for that case your solution works but I also had such strings to test :

java script:function("blabh"),'test','200')

so .. ASCII is mandatory here :) since there are " and ' in the string to test

Not really: Just double them up like:
' java script:function("blabh"),''test'',''200'')'

Jos :)

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

well that's what I typed in my previous post :)

but I prefer using ASCIIs

Edited by MikeP

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0