mIRC Home    About    Download    Register    News    Help

Print Thread
Locate number within string of words #234041 02/10/11 06:54 PM
Joined: Nov 2009
Posts: 17
A
AD1C Offline OP
Pikka bird
OP Offline
Pikka bird
A
Joined: Nov 2009
Posts: 17
I am working on a script that parses the data in strings like this:

(W6RK-Bot) spot: W6JTI Humboldt, CA (fixed) 28043.3 CW

I want to locate the number in the string, i.e. 28043, and check to see if it's within a numerical range (ie. 28000-29700). I looked at isin() and iswc() but neither seems to be sufficient for my needs. The string above is an example, there can be more/fewer words both before and after the number. How can I do this?


Jim Reisert
http://www.ad1c.us/
Re: Locate number within string of words [Re: AD1C] #234042 02/10/11 07:19 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Code:
noop $regex($1-,/ (\d+)/)
if ($regml(1) isnum 28000-29700) {

Re: Locate number within string of words [Re: Tomao] #234043 02/10/11 09:01 PM
Joined: Nov 2009
Posts: 17
A
AD1C Offline OP
Pikka bird
OP Offline
Pikka bird
A
Joined: Nov 2009
Posts: 17
Will this also work?

noop $regex(%spotline,/ (\d+)/)
if ($regml(1) isnum 28000-29700) {


Jim Reisert
http://www.ad1c.us/
Re: Locate number within string of words [Re: AD1C] #234044 02/10/11 09:32 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Yes, it'll work if the variable %spotline contains the string you want to match. The regex will catch the number before the decimal point and then compare it to see if it's within the range 28000 to 29700, as shown. I don't know what your actual script looks like. The example I've come up with above is merely based on your description.

Re: Locate number within string of words [Re: Tomao] #234060 03/10/11 09:32 PM
Joined: Nov 2009
Posts: 17
A
AD1C Offline OP
Pikka bird
OP Offline
Pikka bird
A
Joined: Nov 2009
Posts: 17
It's all working fine, thanks.


Jim Reisert
http://www.ad1c.us/