Jump to content

String Replace keeps saying undefined function


Flum
 Share

Recommended Posts

 Hi all,

Im trying to replace a string with only relevant information. My first thought was the stringreplace function.

 

The string i wish to cutdown:

HospitalInfo.set2("HospitalInfoCash", "<b>Cash</b> - ","&euro;&nbsp;1,270,876");

 The information i would like to keep is the cash amount:

1,270,876

From the helpfile:

#include <MsgBoxConstants.au3>

; Replace a blank space (' ') with a - (minus) character.
Local $sString = StringReplace("This is a sentence with whitespace.", " ", "-")
Local $iReplacements = @extended
MsgBox($MB_SYSTEMMODAL, "", $iReplacements & " replacements were made and the new string is:" & @CRLF & @CRLF & $sString)

Now after some research i found out u cant use double quotes. So i searched the forum and found out u should wrap the double quotes into single quotes.

So i tried to search on this for the replacement:

HospitalInfo.set2('"'HospitalInfoCash'"', '"'<b>Cash</b> - '"','"'&euro;&nbsp;1,270,876");

Sadly, i am still getting a syntax error. Could someone point me in the right direction.

Link to comment
Share on other sites

Hi,
If you want to show quotes in quotes or single quotes in single quotes then double it or wrap it with the contrary like you said.
 
RegEx may be more appropriate :

$s = 'HospitalInfo.set2("HospitalInfoCash", "<b>Cash</b> - ","&euro;&nbsp;1,270,876");'
 
$a = StringRegExp($s, '&nbsp;([\d,]+)"', 3)
 
ConsoleWrite($a[0] & @Lf)

_
Br, FireFox.

Edited by FireFox
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

×
×
  • Create New...