Jump to content

[SOLVED] Syntax problem. Regexp with "


Recommended Posts

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
Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Moderators

$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.

Link to comment
Share on other sites

$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
Link to comment
Share on other sites

  • Moderators

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.

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...