This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.
For more information, see this announcement post . Click the X in the top right-corner of this box to dismiss this message.
Old posts that have not been replied to for several years.
cerberus_gr
Halfop
Posts: 97 Joined: Fri Feb 07, 2003 8:57 am
Location: 127.0.0.1
Post
by cerberus_gr » Thu Feb 05, 2004 7:38 pm
Hello,
Because I can't understand regexp could someone help me?
I want to use regexp in order to check if two words are in a sentence.
What I mean...
I have the lines:
abc def ghi jkl
abc dek jjs kks
abd jjs hsh ghi
and I want to search for abc AND ghi. I want to use regexp and this to return only 1st line.
What Should I do?
In mirc scripting this command is string1*string2, where * can contain 0 or more chrs. I want the same "method" for the regexp...
strikelight
Owner
Posts: 708 Joined: Mon Oct 07, 2002 10:39 am
Contact:
Post
by strikelight » Thu Feb 05, 2004 10:58 pm
you could use regexp, but 'string match' is more suited for this type of problem.
Code: Select all
if {[string match "*abc*ghi*" $line]} { ... abc and ghi are in this line ... }
cerberus_gr
Halfop
Posts: 97 Joined: Fri Feb 07, 2003 8:57 am
Location: 127.0.0.1
Post
by cerberus_gr » Sat Feb 07, 2004 1:13 pm
I want to use grep command of linux so I need this syntax. Grep command has the same syntax as regexp.
Is there any better way to search 4 folders with 100 files each one for a string than grep command?
Thx
strikelight
Owner
Posts: 708 Joined: Mon Oct 07, 2002 10:39 am
Contact:
Post
by strikelight » Sat Feb 07, 2004 1:28 pm
Since this is a tcl forum, I recommend taking a look at the "glob" command in the TCL manpages, instead of talking about unix commands.
cerberus_gr
Halfop
Posts: 97 Joined: Fri Feb 07, 2003 8:57 am
Location: 127.0.0.1
Post
by cerberus_gr » Sat Feb 07, 2004 1:56 pm
In a code i can use unix commands, such as lynx, wget etc. A lot of tcl scripts have one "clean" unxi command. So why is this a problem if I use the grep command.
Althought I have tcl 8.0 and glob has just one option
Is the glob command so quick as the grep is?
Sorry, if my post isn't about tcl
cvanmeer
Halfop
Posts: 40 Joined: Tue Dec 02, 2003 1:00 pm
Location: The Netherlands
Contact:
Post
by cvanmeer » Mon Feb 09, 2004 3:34 am
here is a lil thingie to help you get started.
Code: Select all
set lookup [open "|/bin/grep -R #TINGIE YOU WANT TO SEARCH FOR# $arg"]
while {![eof $lookup]} {
catch {set result [gets $lookup]}
putserv "PRIVMSG $nick :$result"
}
catch {close $lookup}
return 1
hope it helps.
gr.
Chris
cerberus_gr
Halfop
Posts: 97 Joined: Fri Feb 07, 2003 8:57 am
Location: 127.0.0.1
Post
by cerberus_gr » Fri Feb 13, 2004 5:21 pm
Thx a lot, it's working