Position> substring contains a comma

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
dafe
Junior Coder
Posts: 23
Joined: Sun Apr 06, 2008 4:21 am

Position> substring contains a comma

Post by dafe » Wed Sep 03, 2008 8:06 am

Hi,

I need to locate the following from inside variable %HTMLResponse%

LOCATION: %suburb%, QLD

however, the following won't work

Code: Select all

Position><strong>LOCATION:</strong> %suburb%, QLD<br>,HTMLResponse,1,pos
Because the comma in my substring cause ms to think that

Code: Select all

 QLD<br>
is my string to search, instead of HTMLResponse.

is there any way around this? it's important that the substring remain as it is
--

dafe
Junior Coder
Posts: 23
Joined: Sun Apr 06, 2008 4:21 am

Post by dafe » Wed Sep 03, 2008 8:11 am

nvm, i'm an idiot.

for anyone else -

Code: Select all

Let>test=<strong>LOCATION:</strong> %suburb%, QLD<br>
Position>%test%,HTMLResponse,1,pos
on an unrelated note - is it possible to have position> continue searching a document after it finds the first instance of a specified substring? i.e. can you retrieve multiple finds into multiple vars?
--

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Sep 03, 2008 10:01 am

The following will keep searching a string and put all matching positions into an array:

Code: Select all

Let>test=A
Let>HTMLResponse=A D A F A G A

Let>start=1
Length>HTMLResponse,len
Let>k=0
Repeat>start
  Let>k=k+1
  Position>%test%,HTMLResponse,%start%,pos,FALSE
  Let>PosArr[%k%]=pos
  Let>start={%pos%+1}
Until>start>len
So for the above text data you end up with:

PosArr[1]=1
PosArr[2]=5
PosArr[3]=9
PosArr[4]=13
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts