AutoHotkey Community

It is currently May 27th, 2012, 10:51 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 789 posts ]  Go to page Previous  1 ... 42, 43, 44, 45, 46, 47, 48 ... 53  Next
Author Message
 Post subject:
PostPosted: January 10th, 2012, 11:43 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5482
Location: the tunnel(?=light)
Code:
Haystack :=   "01*02*03*04*05*TEXT1*TEXT2*TEXT3"
Haystack :=   RegExReplace(Haystack,"^.*?\*(?=\D)")   ; remove everything up to the first star followed by a non-digit
Loop, parse, Haystack, *   ; parse 'Haystack'
   if   A_Index > 2   ; only parse the first two stars since the third term might have a star
      break
   else   var%A_Index% :=   A_LoopField
var3 :=   SubStr(Haystack,StrLen(var1)+StrLen(var2)+3)
MsgBox %   var1 "`n" var2 "`n" var3

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 11th, 2012, 12:34 am 
that worked, thanks


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 27th, 2012, 4:18 pm 
Offline

Joined: June 7th, 2007, 1:33 pm
Posts: 1019
which regex code represents any zero or more character, I mean ANY character, newline, symbol, digit, ANYTHING


also, \h that represents any whitespace character (space, tab, but not newline, or other) does not seem to work, which is the alternative?

thanks


Last edited by azure on February 27th, 2012, 4:24 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 27th, 2012, 4:24 pm 
A dot (.) combined with the s (DotAll) option. Described in doc so don't ask how, why, example etc as it is already in the help file.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 27th, 2012, 10:01 pm 
Offline
User avatar

Joined: November 2nd, 2008, 4:23 pm
Posts: 2906
Location: 127.0.0.1
Space or tab: [\s\t]

For the any character; use the DOTALL option where you can. Everywhere else I end up using (.|\n).

_________________
aboutscriptappsscripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 27th, 2012, 10:40 pm 
Offline

Joined: June 7th, 2007, 1:33 pm
Posts: 1019
I did not find sufficient documentation for DotAll, but it seems I just need to place (?s) before the dot to enable it

it complicates alot the code (because, first, s is meant for space, second, I dont know where it is enabled and where it is not, third, I need to disable it if I dont want to use it, etc), so, I came up with this, that seems to do the job:

Code:
(\t|\n|.|\r)*


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 27th, 2012, 11:07 pm 
Offline
User avatar

Joined: November 2nd, 2008, 4:23 pm
Posts: 2906
Location: 127.0.0.1
That's just a less efficient version of (\n|.)*.

_________________
aboutscriptappsscripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 28th, 2012, 3:53 pm 
Offline

Joined: July 10th, 2008, 8:49 am
Posts: 1865
Location: Brussels, Belgium
Frankie wrote:
That's just a less efficient version of (\n|.)*.


OMG !

Your post was the 666th post in this topic ! :twisted:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 28th, 2012, 4:10 pm 
azure wrote:
I did not find sufficient documentation for DotAll, but it seems I just need to place (?s) before the dot to enable it
As there are only three RE related pages in the documentation you must be joking. DotAll is described perfectly, no need for further documentation.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 28th, 2012, 8:14 pm 
Offline

Joined: June 7th, 2007, 1:33 pm
Posts: 1019
I cant make it work:

Code:
RunWait, pdftotext -f 1 -l 1 -layout 1.pdf x-timestamp.txt
FileRead, xx, x-timestamp.txt
ClientID := RegExReplace("%xx%" , "sm).*^COMPANY NAME\h+: (.+)$sm).*" , "$1")
FileMove, 1.pdf, %ClientID%.pdf


what's wrong with it?

:?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 28th, 2012, 8:25 pm 
I'll give you a hint, you can only pass on the options once, you do it twice, why, where is that documented? Do as the docs say, not as your imagination tells you ;-)
Code:
RegExReplace("%xx%" , "sm).*^COMPANY NAME\h+: (.+)$sm).*" , "$1")


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 28th, 2012, 8:27 pm 
Offline

Joined: March 10th, 2008, 12:55 am
Posts: 1907
Location: Minnesota, USA
I'll give you another hint: you don't use %'s in an expression and functions.
Code:
RegExReplace("%xx%" , "sm).*^COMPANY NAME\h+: (.+)$sm).*" , "$1")


also, lose the "quotes" around the xx.

_________________
rawr. be very afraid
*poke*
Note: My name is all lowercase for a reason.
"I think Bigfoot is blurry, that's the problem. It's not the photographer's fault, Bigfoot is blurry. So there's a large, out-of-focus monster roaming the countryside."


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 29th, 2012, 8:40 pm 
Offline

Joined: June 7th, 2007, 1:33 pm
Posts: 1019
aaarrggghhh it still doesnt work:

Code:
RunWait, pdftotext -f 1 -l 1 -layout 1.pdf x-timestamp.txt
FileRead, xx, x-timestamp.txt
msgbox %xx%
ClientID := RegExReplace(xx, "m).*^COMPANY NAME\s+: (.+)$.*", "$1")
msgbox %ClientID%
FileMove, 1.pdf, %ClientID%.pdf


both xx and ClientID are the whole text of the x-timestamp.txt, while it should be only the (.+) of the "sm).*^COMPANY NAME\s+: (.+)$.*"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 3rd, 2012, 12:40 pm 
Offline

Joined: June 7th, 2007, 1:33 pm
Posts: 1019
any help with the above?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 3rd, 2012, 5:55 pm 
Make it simple.
Show me your haystack for example.


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 789 posts ]  Go to page Previous  1 ... 42, 43, 44, 45, 46, 47, 48 ... 53  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, chaosad, Google [Bot], Google Feedfetcher, HotkeyStick, krajan, Yahoo [Bot] and 30 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group