Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Remove double quotes - regular expression
#1
How do I remove double quotes or replace double quotes to blank space or single quotes in a string? For example in the single long string below (no hard returns in this single string):

<TD vAlign=center><SELECT class=actionBoxdb id=s2 style="WIDTH: 75px" onchange=parent.DoFunction(event.srcElement) LeafletPath="" PrescriptionID="f754524a-8cc3-4eb9-819d-de3d85bdcc0e" scriptid="f754524a-8cc3-4eb9-819d-de3d85bdcc0e" statustask="" statusnotes="" status="0" Quantity="30" Refills="prn" SIG="1 po qAM" Dose="30 mg" Prescription="Prevacid"><OPTION value=details selected>details</OPTION><OPTION value=stop>stop</OPTION><OPTION

I want to remove or replace all double quotes and THEN match the "s2" when it follows "id=" (lookbehind) and precedes "Prevacid" (lookahead). I can't seem to use regular expressions until the double quotes are removed and I can't use regular expressions to remove the double quotes either. Should I use Vbscript RegEx to first remove the quotes and then return to using PCRE in QuickMacros?
#2
To remove or replace double quotes use str function findreplace.

Code:
Copy      Help
str s="<TD..."
s.findreplace("''" "'")
#3
Thank you. I tried the s.findreplace("''" "'") solution. My problem seems to occur when the first double quote in the string is reached. In this example, that double quote is just before the word WIDTH, but the string is not finished yet. Is this a problem with smart double quotes vs. straight double quotes? These double quotes are the same type of double quotes that define the beginning and end of a string. I have been able to use regular expressions in Quick Macros as long as there are no double quotes in the strings involved in either the subject string or the RegEx string.

str s = "<TD vAlign=center><SELECT class=actionBoxdb id=s2 style="WIDTH: 75px..."
#4
lets see your code....i think it may be how your assigning your var value.
An old blog on QM coding and automation.

The Macro Hook
#5
Problem when assigning a string containing " to a variable? Replace " to two '. You can use the Text dialog for this.

Code:
Copy      Help
str s ="<TD vAlign=center><SELECT class=actionBoxdb id=s2 style=''WIDTH: 75px..."

Another way - assign comments:

Code:
Copy      Help
str s =
;<TD vAlign=center><SELECT class=actionBoxdb id=s2 style="WIDTH: 75px...
#6
Gintaras Wrote:Problem when assigning a string containing " to a variable? Replace " to two '. You can use the Text dialog for this.

Code:
Copy      Help
str s ="<TD vAlign=center><SELECT class=actionBoxdb id=s2 style=''WIDTH: 75px..."

Another way - assign comments:

Code:
Copy      Help
str s =
;<TD vAlign=center><SELECT class=actionBoxdb id=s2 style="WIDTH: 75px...
i have read a lot of your posts and it has a lot about text dialog. i was wondoring where i can find more about it at. ty -b
#7
I'm not sure why this is working now, but it seems to be working despite all the double quotes in the string. I'm new to macros and modern programming. I programmed a little, many years ago in Pascal and Fortran and Turbo Basic but have no training in Visual Basic, C++, etc.. I'm not sure what you mean by using the Text Dialog.

I am trying to improve a poor user interface of a medical software application that I must use by making my own interface. Once completed, I want my interface to drive the built-in application interface. This is primarily a browser-based application that can be manipulated by the HTML element menu commands. There are also some standard windows that also pop up and these must be manipulated with Window/control actions menu instead of the HTML element menu.

In this example below, I get a list of the Html code for the medication section. I have shown part of this code that pertains to the medication Nexium. The actual Quick Macros code is shown below:

Htm el=htm("BODY" "" "" win("gCare2 - Microsoft Internet Explorer" "IEFrame") "3/2/7/1" 0 0x20)
str s=el.HTML

the string s actually contains the following text -- this string is a lot larger than the extracted part shown below. Note

all the double quotes:

<TD vAlign=center><SELECT class=actionBoxdb id=s2 style="WIDTH: 75px" onchange=parent.DoFunction(event.srcElement)

LeafletPath="" PrescriptionID="c1a8624a-5b23-4703-9d63-829294ad7bc0" scriptid="c1a8624a-5b23-4703-9d63-829294ad7bc0"

statustask="" statusnotes="" status="0" Quantity="30" Refills="10" SIG="1 po qd" Dose="40 mg" Prescription="Nexium"><OPTION

value=details selected>details</OPTION><OPTION value=stop>stop</OPTION><OPTION value=refill>refill</OPTION><OPTION

value=medhis>med history</OPTION><OPTION value=modify>modify</OPTION><OPTION value=void>void</OPTION><OPTION

value=voidlastrefill>void last refill</OPTION></SELECT>&nbsp;<IMG onclick=parent.DoFunction(s2);

src="https://gmed.ganapc.net/gcare2/images/go.gif" align=absMiddle></TD></TR>

In this example, I need to find s2 which is seen on the first line just after id=

str subject=s ;; as above, s=el.HTML
str StringThatisFound
str FirstRegularExpressionToLookFor="(?<=id=)\bs\d{1,2}(?=.*Nexium)" ;; find a string such as s1 or s2 or s12 or s20 that is preceeded by id= and is followed at some point by Nexium.

if(findrx(subject FirstRegularExpressionToLookFor 0 0 StringThatisFound)>=0)
out StringThatisFound ;; output of StringThatisFound = s2

I then use s2 to access a different area of the program to refill or stop this prescription.

el=htm("SELECT" StringThatisFound "" win("gCare2 - Microsoft Internet Explorer" "IEFrame") "3/2/7/1" 1 0x121)
el.SetFocus
el.Mouse(1)
key s ;; to type the s choice in the application menus that means "stop" or discontinue the Nexium prescription.

I have been looking at Excel as a way to display a large amount of data at one time and use this to add data to the application that is being driven by Quick Macros. For example: If Cell A1 contains "Nexium 40 mg,one PO daily, #30" then by typing "3r" (which represents "3 refills") into cell B1, I could use Quick Macros to enter 3 refills of Nexium into the application. I'm trying to decide if I should: 1. trigger VBA macros from Quick Macros first and then send the final results to Quick Macros for driving the application, or 2. if I should use Quick Macros exclusively to manipulate the Excel Spreadsheet before using the final results to drive the application.
#8
If the subject string (part of it from s2 to Nexium) is multiline, insert (?s) at the beginning of the regular expression. It sets option ". matches new line characters too".


Forum Jump:


Users browsing this thread: 1 Guest(s)