Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
findrx question
#1
Hi there,

When i'm using this code:

variables
str s1
ARRAY(str) a
activate notepad, select all, get all text into s1
act "Kladblok"
key Ca
s1.getsel
use regular expression to find and extract text between . and !
if(findrx(s1 "\$(.+?)!" 0 4 a)<0) ret ;;exit if not found
a now contains all instances of text between . and !
activate QM and display a
act _hwndqm
int i
for i 0 a.len
out a[1 i]
mes a[1 i]

and the text is devided in multiple lines nothing is selected and i'm getting nothing back. What is wrong with it or am i missing something. It is ment to select a piece of text of several lines and copy this.

TIA
#2
Replace "\$" to "\.".
#3
OK, thats not what i meant.

A text like this one:

.hjfkghskfhgksfhgksjfhgkshgs
sfgsfgsfgsgs
sfgsfgsgfsfg!

Is not returned by this macro but when i put .test! on top of it, it returns test, so it only works if the output contains one single line or something with no enter/return in it. That is my problem. I want it to return : .hjfkghskfhgksfhgksjfhgkshgs
sfgsfgsfgsgs
sfgsfgsgfsfg!

PS the $ was a typo :-)

TIA
#4
"(?s)\.(.+?)!"

(?s) sets "dot matches new line characters too" option.
#5
Thank you, now i'm happy! :lol:
#6
Is it possible to let is stop searching after first find? So if text has several ! as in sample when it finds the first one it stops and selects?
#7
are you sure it doesn't already? i was thinking the the rx in qm is 'eager'.
An old blog on QM coding and automation.

The Macro Hook
#8
Code:
Copy      Help
int i j
i=findrx(alltext regexp 0 0 j)
if(i<0) ret
SendMessage id(15 "Notepad") EM_SETSEL i i+j


EM_SETSEL can be used only with edit controls (eg Notepad) and rich edit controls (eg Wordpad).


Forum Jump:


Users browsing this thread: 1 Guest(s)