trigger and regex help

tarrant
Posts: 49
Joined: Thu Apr 15, 2010 10:36 pm

trigger and regex help

Post by tarrant »

I have this line, 83949204LLL.
How do i capture the first 5 numbers into 1 variable, the next 3 numbers into another variable and the next 3 letters into yet another variable. All the numbers and letters can change.

Also, is there a way for a trigger to capture say, the next 100 characters. Or next 20 characters. Instead of next 2 or 3 lines.

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: trigger and regex help

Post by tsuujin »

(\d{,5})(\d{,3})(\w{,3})

next x characters:
(.{,x})
change x to a number you wish.
(.{,100})

tarrant
Posts: 49
Joined: Thu Apr 15, 2010 10:36 pm

Re: trigger and regex help

Post by tarrant »

What if its all in the same line?
As in, using the above example.
83949204LLL204charactersworthoftextornumbers
I'll capture 83949, 204, LLL then i wanna capture 204charactersworthoftextornumbers.
It'll all be in 1 line like the above.
So it could be 73848398HHH398charactersworthoftextornumbers, and i'll wanna capture all the 398 characters following the HHH.

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: trigger and regex help

Post by tsuujin »

Why don't you give me an actual example of what you're trying to do, rather than abstracts?

tarrant
Posts: 49
Joined: Thu Apr 15, 2010 10:36 pm

Re: trigger and regex help

Post by tarrant »

Hmm,
#K%75560007BAE0.00
#K%75560008AAC23:05#K%75560011AAF1.7 days
In the second line, it's not a typo, sometimes they appear together that way in 1 line.

Thanks for your time and help.

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: trigger and regex help

Post by tsuujin »

tarrant wrote:Hmm,
#K%75560007BAE0.00
#K%75560008AAC23:05#K%75560011AAF1.7 days
In the second line, it's not a typo, sometimes they appear together that way in 1 line.

Thanks for your time and help.
All right. What is that? What information are you trying to pull out of it, and why? If I know that, I can come up with the regex.

How are you going to use the information you get?

tarrant
Posts: 49
Joined: Thu Apr 15, 2010 10:36 pm

Re: trigger and regex help

Post by tarrant »

It is Portal MIP. You can read about it here
#K%75560007BAE0.00
#K%75560008AAC23:05#K%75560011AAF1.7 days
Basically, 75560 is just a random number, 007 is the number of characters that will be sent after the 007, BAE is the kind/type of information sent and 0.00, in this case, is the info sent.

I want to capture the info and echo it to different windows/miniconsoles based on the 3 letters preceding the info.

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: trigger and regex help

Post by tsuujin »

tarrant wrote:It is Portal MIP. You can read about it here
#K%75560007BAE0.00
#K%75560008AAC23:05#K%75560011AAF1.7 days
Basically, 75560 is just a random number, 007 is the number of characters that will be sent after the 007, BAE is the kind/type of information sent and 0.00, in this case, is the info sent.

I want to capture the info and echo it to different windows/miniconsoles based on the 3 letters preceding the info.
Regex:

Code: Select all

(.{,3})(\d{,5})(\d{0,3})(\w{,3})(.+)
Examples:

Code: Select all

#K%75560007BAE0.00
matches[1] = #K%75560007BAEBAE0.00
matches[2] = #K%
matches[3] = 75560
matches[4] = 007
matches[6] = BAE
matches[7] = 0.00

Code: Select all

#K%75560008AAC23:05#K%75560011AAF1.7 days
matches[1] = #K%75560008AAC23:05#K%75560011AAF1.7 days
matches[2] = #K%
matches[3] = 75560
matches[4] = 008
matches[6] = AAC
matches[7] = 23:05#K%75560011AAF1.7 days
I -think- that's what you're asking for.

tarrant
Posts: 49
Joined: Thu Apr 15, 2010 10:36 pm

Re: trigger and regex help

Post by tarrant »

Hmm, what you gave didn't seem to work, so I modified it a little to

Code: Select all

#K%\d{5}(\d{3})(\w{3})
However, there is a problem with the second line where the 2 occurences are appearing at the same time,
#K%75560008AAC23:05#K%75560011AAF1.7 days
I need to capture #K%75560008AAC23:05 and #K%75560011AAF1.7 days separately. I thought the match all option would fix it, but it doesn't seem to work when the code is

Code: Select all

#K%\d{5}(\d{3})(\w{3})(.*)
cuz the .* just matches everything. If i remove the (.*) from the trigger, it will match all occurences within the same line properly.

Hmm, is it understandable? Not really sure how to make this clearer.

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: trigger and regex help

Post by Heiko »

Link to a good PCRE tutorial: http://www.regular-expressions.info/reference.html

Here's a link to the complete pcre manual: http://www.pcre.org/pcre.txt

Post Reply