|
Joined: Feb 2003
Posts: 8
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Feb 2003
Posts: 8 |
hi. if any1 could help me with this i would really appreciate it 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
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,523 |
Assuming we're in /search alias, use this pattern with /filter: /\\[^\\]* $+ $1 $+ [^\\]*$/
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
|
|
|
|
Joined: Feb 2003
Posts: 8
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
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.. 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.
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,523 |
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
|
|
|
|
Joined: Feb 2003
Posts: 8
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
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
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,523 |
Oops, you're right, my mistake. Try this: 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
|
|
|
|
Joined: Feb 2003
Posts: 8
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Feb 2003
Posts: 8 |
tnx alot qwerty, works great now! // mattiaz
|
|
|
|
|