Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
file reading
#1
Hi

Anyone knows how to make macro to find a piece of text between two chars?

I have text in notepad and i need my macro to read text between "." and "!" chars and put it into some string var.

Like .hello! , so it finds it and assigns "hello" to s var.

Thanks
#2
Code:
Copy      Help
;variables
str s1 s2
;activate notepad, select all, get all text into s1
act "Notepad"
key Ca
s1.getsel
;use regular expression to find and extract text between . and !
if(findrx(s1 "\.(.+?)!" 0 0 s2 1)<0) ret ;;exit if not found
;s2 now contains text between . and !
;activate QM and display s2

act _hwndqm
out s2

This code finds all instaces of text between . and !
Code:
Copy      Help
;variables
str s1
ARRAY(str) a
;activate notepad, select all, get all text into s1
act "Notepad"
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]


Forum Jump:


Users browsing this thread: 1 Guest(s)