Jump to content

StringReplace


 Share

Recommended Posts

$read = StringReplace( $read1, " <span class="smgrayText" style="font-size: 12px;">Time:</span> <span style="font-size: 12px;" class="runtime">", "" )

when i do this after the first ";" it goes green how do i work around that?

Edited by butji
Link to comment
Share on other sites

Please show enough code to test this line. Thanks...

when i do this after the first ";" it goes green how do i work around that?

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

$read1 = "<span class="smgrayText" style="font-size: 12px;">Time:</span> <span style="font-size: 12px;" class="runtime">03:35</span>"

$read = StringReplace( $read1, "<span class="smgrayText{"} style="font-size: 12px;">Time:</span> <span style="font-size: 12px;" class="runtime">", "" )

Link to comment
Share on other sites

I tried running your example code and got this error:

C:\Examples\junk.au3(1,24) : ERROR: syntax error
$read1 = "<span class="smgrayText
~~~~~~~~~~~~~~~~~~~~~~~^
C:\Examples\junk.au3(2,46) : ERROR: syntax error (illegal character)
$read = StringReplace( $read1, "<span class="smgrayText
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Examples\junk.au3 - 2 error(s), 0 warning(s)
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

YEA thats the problem... how do i work around that?

<span class="smgrayText" style="font-size: 12px;">Time:</span> <span style="font-size: 12px;" class="runtime">

i want this to be 1 string not to be parted in 20 different because of all the "s

Link to comment
Share on other sites

  • Moderators

Try wrapping the string in single quotes if your string contains double quotes:

$read = StringReplace( $read1, '" <span class="smgrayText" style="font-size: 12px;">Time:</span> <span style="font-size: 12px;" class="runtime">"', "" )

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

$read = StringReplace( $read1, " <span class="smgrayText" style="font-size: 12px;">Time:</span> <span style="font-size: 12px;" class="runtime">", "" )

when i do this after the first ";" it goes green how do i work around that?

LOL -- I had to read this a few times to figure out what you were talking about. I must be tired.

The character ";" tells AutoIt to ignore this as code and that it's the beginning of a comment. That's why its going green, SciTE is trying to tell you through colors how the your code will be read when executed. To get around this you'll need to do something like:

$var = "class="& Chr(34)&"smgrayText"& Chr(34) 
MsgBox(0,"Debug: ASCII Codes", "$var contains the string:  " & $var)

Search the au3 help file for CHR and also ASCII Codes. There's a number that will represent the semicolon. Hope this helped and good luck!

BTW, you should also study up on the IE.au3 and or the INet.au3 functions. Remember there's usually a better way of doing everything.

Link to comment
Share on other sites

Try wrapping the string in single quotes if your string contains double quotes:

$read = StringReplace( $read1, '" <span class="smgrayText" style="font-size: 12px;">Time:</span> <span style="font-size: 12px;" class="runtime">"', "" )
Always listen to an MVP over anyone else! Usually the smarter and easier way of doing things. Thanks SmOke_N, one more nugget of info to add to collection!
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...