Sign in to follow this  
Followers 0
dinodod

IE String replace with QUOTES inside

10 posts in this topic

Here is a sample of what I am trying to do:

$sHTML = StringReplace($sHTML, """<img alt="Google" height=110 src="/intl/en_ALL/images/logo.gif" width=276>""", "")

As you can imagine, it's a very common practice to use " [ Quotes ] in HTML but I am trying to create a filter to remove certain lines of text from the page PRIOR to seeing it.

Since the text I will be replacing will contain any number of Quotes and other characters, I am at a loss as to how to actually proceed. Double quotes around the text doesn't work (Too easy).

I was thinking of perhaps converting the characters to their [ string equivilant (&Quo) ] ????? then replacing the text that matches then converting back?


Digital Chaos - Life as we know it today.I'm a Think Tank. Problem is, my tank is empty.The Quieter you are, the more you can HearWhich would you choose - Peace without Freedom or Freedom without Peace?Digital Chaos Macgyver ToolkitCompletely Dynamic MenuSQLIte controlsAD FunctionsEXCEL UDFPC / Software Inventory UDFPC / Software Inventory 2GaFrost's Admin Toolkit - My main competitor :)Virtual SystemsVMWAREMicrosoft Virtual PC 2007

Share this post


Link to post
Share on other sites



Have you tried putting single quotes around them? ( ' " ' )


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Have you tried putting single quotes around them? ( ' " ' )

Single Quotes? LOL, OMG That would be too easy woudn't it? Um, single quotes around the entire string or each quote?

Let me see :)

Update:

"<img alt='"'Google'"' height=110 src='"'/intl/en_ALL/images/logo.gif'"' width=276>" <-- errors out

'<img alt="Google" height=110 src="/intl/en_ALL/images/logo.gif" width=276>' <-- Doesn't work

Funny, this shows that temp = <img alt="Google" but it stil doesn't match in $sHTML which is the _IEBodyReadHTML of Google.com!

$temp = '<img alt="Google"'
$result = StringInStr($sHTML, $temp)
MsgBox(0, "Search result: 0=Bad", $result & @CRLF & $temp)
Edited by dinodod

Digital Chaos - Life as we know it today.I'm a Think Tank. Problem is, my tank is empty.The Quieter you are, the more you can HearWhich would you choose - Peace without Freedom or Freedom without Peace?Digital Chaos Macgyver ToolkitCompletely Dynamic MenuSQLIte controlsAD FunctionsEXCEL UDFPC / Software Inventory UDFPC / Software Inventory 2GaFrost's Admin Toolkit - My main competitor :)Virtual SystemsVMWAREMicrosoft Virtual PC 2007

Share this post


Link to post
Share on other sites
:) bump :)

Digital Chaos - Life as we know it today.I'm a Think Tank. Problem is, my tank is empty.The Quieter you are, the more you can HearWhich would you choose - Peace without Freedom or Freedom without Peace?Digital Chaos Macgyver ToolkitCompletely Dynamic MenuSQLIte controlsAD FunctionsEXCEL UDFPC / Software Inventory UDFPC / Software Inventory 2GaFrost's Admin Toolkit - My main competitor :)Virtual SystemsVMWAREMicrosoft Virtual PC 2007

Share this post


Link to post
Share on other sites

Hi,

hmm, I do not get what you got, what to be replaced and what should the result look like?

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Hi,

hmm, I do not get what you got, what to be replaced and what should the result look like?

Mega

In short, I am trying to search thru some HTML code for some strings, which includes " & ' characters. I can't use my command since those characters are breaking the syntax.

I need to be able to use my commands and somehow be able to ignore those special characters.

Here is a better example. As you can see this string is from Google's main page. I want to find this string and remove it from the HTML source. The problem is that the string has those nice quotes and dashes in it. How can I resolve this if it contains quotes and dashes?

$temp = "<img alt="Google" height=110 src="/intl/en_ALL/images/logo.gif" width=276>" 
MsgBox(0, "", $temp)

$temp = '<img alt="Google" height=110 src="/intl/en_ALL/images/logo.gif" width=276>'
MsgBox(0, "", $temp)
Edited by dinodod

Digital Chaos - Life as we know it today.I'm a Think Tank. Problem is, my tank is empty.The Quieter you are, the more you can HearWhich would you choose - Peace without Freedom or Freedom without Peace?Digital Chaos Macgyver ToolkitCompletely Dynamic MenuSQLIte controlsAD FunctionsEXCEL UDFPC / Software Inventory UDFPC / Software Inventory 2GaFrost's Admin Toolkit - My main competitor :)Virtual SystemsVMWAREMicrosoft Virtual PC 2007

Share this post


Link to post
Share on other sites

Hi,

okay, what are your commands? Show me

$string ...

before

after

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

In short, I am trying to search thru some HTML code for some strings, which includes " & ' characters. I can't use my command since those characters are breaking the syntax.

I need to be able to use my commands and somehow be able to ignore those special characters.

Here is a better example. As you can see this string is from Google's main page. I want to find this string and remove it from the HTML source. The problem is that the string has those nice quotes and dashes in it. How can I resolve this if it contains quotes and dashes?

$temp = "<img alt="Google" height=110 src="/intl/en_ALL/images/logo.gif" width=276>" 
MsgBox(0, "", $temp)

$temp = '<img alt="Google" height=110 src="/intl/en_ALL/images/logo.gif" width=276>'
MsgBox(0, "", $temp)
AFAIK, you encode quotes by doubling them up

I shall state "Hello there" he said

becomes

$vari="I shall state ""Hello there"" he said"

Edited by everseeker

Everseeker

Share this post


Link to post
Share on other sites

AFAIK, you encode quotes by doubling them up

I shall state "Hello there" he said

becomes

$vari="I shall state ""Hello there"" he said"

i'm having the same problem here. I've tried the other 2 solutions presented, they dont work. Anyone to save the day on this one?

CODE
$temp2 = """

$temp = StringLeft($temp, StringInStr($temp, " balance"))

$temp = StringRight($temp, StringLen($temp) - StringInStr($temp, "name="))

StringReplace($temp, $temp2, "")

I'm using the $temp2 variable because if i write directly StringReplace($temp, """, "") SciTe doesn't understand. I've tried things like "\"", doesn't work neither....

thanks.

Share this post


Link to post
Share on other sites

Hi,

I still do not understand where you problem is. :)

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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