mIRC Home    About    Download    Register    News    Help

Print Thread
#70139 03/02/04 12:39 AM
Joined: Feb 2003
Posts: 8
M
mattiaz Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Feb 2003
Posts: 8
hi. if any1 could help me with this i would really appreciate it smile

i'm making a search script which searches a txt file using /filter,
but i only want it to match the text efter the last backslash..

lets say my txtfile has this in it.
c:\test
c:\bla\test.txt
c:\TesT\bla.txt
c:\program files\Test
c:\program files\bla\TEST.txt
c:\program files\test\Bla.txt

so right now /search test would match all these lines but i just want it to match
c:\test
c:\bla\test.txt
c:\program files\Test
c:\program files\bla\TEST.txt

hopefully this is possible using filter and regex.

// mattiaz

#70140 03/02/04 01:34 AM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Assuming we're in /search alias, use this pattern with /filter:
Code:
/\\[^\\]* $+ $1 $+ [^\\]*$/


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#70141 03/02/04 02:10 AM
Joined: Feb 2003
Posts: 8
M
mattiaz Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Feb 2003
Posts: 8
tnx for the reply which works great for what i asked for,
but not exactly how i wanted it to work.. smile
perhaps i should have specified more

my /filter command now is

filter -ffct 1 32 file.txt filtered.txt %search

where %search = $+(*,$replace($1-,$chr(32),$chr(42)),*)

so /search test would make %search *test*
and /search t e s t would make %search *t*e*s*t*

also i would want it to not be case-sensitive..

// mattiaz

Last edited by mattiaz; 03/02/04 02:14 AM.
#70142 03/02/04 02:24 AM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Code:
var %search = $replace($1-,^,\^,$,\$,.,\.,[,\[,$chr(40),\ $+ $chr(40),$chr(41),\ $+ $chr(41),+,\+,$chr(123),\ $+ $chr(123),$chr(32),*,*,.*,?,.)
filter -ffcgt 1 32 file.txt filtered.txt /(?i)\\[^\\]* $+ %search $+ [^\\]*$/
This uses regex to imitate wildcard behaviour. The big replace is used to replace characters that are considered special in regex with their escape sequences, so that the only "special" chars are * and ?

Last edited by qwerty; 03/02/04 02:26 AM.

/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#70143 03/02/04 02:48 AM
Joined: Feb 2003
Posts: 8
M
mattiaz Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Feb 2003
Posts: 8
works better but still not perfect..
while searching for just one word it works..

but "/search file test"
matches c:\program files\test.txt
which it shouln't..

// mattiaz

#70144 03/02/04 03:05 AM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Oops, you're right, my mistake. Try this:
Code:
var %search = $replace($1-,^,\^,$,\$,.,\.,[,\[,$chr(40),\ $+ $chr(40),$chr(41),\ $+ $chr(41),+,\+,$chr(123),\{,$chr(32),*,*,[^\\]*,?,[^\\])
filter -ffcgt 1 32 file.txt filtered.txt /(?i)\\[^\\]* $+ %search $+ [^\\]*$/


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#70145 03/02/04 03:09 AM
Joined: Feb 2003
Posts: 8
M
mattiaz Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Feb 2003
Posts: 8
tnx alot qwerty, works great now! laugh

// mattiaz


Link Copied to Clipboard