regexp: match string that contains list of chars

Thread Tools Search this Thread
# 8  
Originally Posted by jimcanoa
that it can be done with regexps! I mean, if you can test if a number is a primer number with regular expressions, I refuse to believe this simple thing can't be done Smilie
Of course it can be done with regex, you wrote it in the first post. The question is can it be done simpler? I think not.
# 9  
Your definition of one regex is a bit arbitrary, as I think some things are not included in base regex, like egrep multi-pattern matching using () and |, where an outer super-regex call may be doing many simple-regex calls. A bad regex can really slow things, too, so sometimes three simple is much better than one ugly. Academic problems are fun, but real world solutions are worth dollars.
# 10  

---------- Post updated at 02:20 AM ---------- Previous update was at 02:16 AM ----------

>> s = "cxxbxxc"
=> "cxxbxxc"
>> s["a"] and s["b"] and s["c"] and print "ok"
=> nil
>> s = "cxxbxxa"
=> "cxxbxxa"
>> s["a"] and s["b"] and s["c"] and print "ok"
ok=> nil
>> s = "axxbxxa"
=> "axxbxxa"
>> s["a"] and s["b"] and s["c"] and print "ok"
=> nil


Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed - print only the chars that match a given set in a string

For a given string that may contain any ASCII chars, i.e. that matches .*, find and print only the chars that are in a given subset. The string could also have numbers, uppercase, special chars such as ~!@#$%^&*(){}\", whatever a user could type in without going esoteric For simplicity take... (1 Reply)
Discussion started by: naderra
1 Replies

2. Shell Programming and Scripting

sed to remove newline chars based on pattern mis-match

Greetings Experts, I am in AIX; I have a file generated through awk after processing the input files. Now I need to replace or remove the new-line characters on all lines that doesn't have a ; which is the last character on the line. I tried to use sed 's/\n/ /g' After checking through the... (6 Replies)
Discussion started by: chill3chee
6 Replies

3. Shell Programming and Scripting

Regexp for string that might contain a given character

I'm probably just not thinking of the correct term to search for :-) But I want to match a pattern that might be 'ABC' or '1ABC' there might be three characters, or there might be four, but if there are four, the first has to be 1 (1 Reply)
Discussion started by: jnojr
1 Replies

4. Shell Programming and Scripting

Question on TCL regexp and match

Hello everyone, I'm new in tcl scripting. I'm currently studying a tcl script and came across this line: regexp {(\d+)(\S?)} $opts match opt swi According to my understanding, this line means to search in the opts variable for one or more digit, followed by a non-whitespace character... (2 Replies)
Discussion started by: mar85
2 Replies

5. Shell Programming and Scripting

Repeatable chars in a string

I have a string I keep appending too upto certain amount of chars. Is there some sort of way for me to check the string to see if I hit my limit of repeatable characters? For example, assume I allow for 2 repeatable chars, this will be a valid string Xxh03dhJUX, so I can append the last... (3 Replies)
Discussion started by: BeefStu
3 Replies

6. Shell Programming and Scripting

extract string until regexp from backside

Hi, I searched in the forums, but I didn't find a good solution. My problem is: I have a string like "TEST.ABC201005.MONTHLY.D101010203". I just want to have the string until the D100430, so that the string should look like: "TEST.ABC201005.MONTHLY.D" The last characters after the D can be... (8 Replies)
Discussion started by: elifchen
8 Replies

7. Shell Programming and Scripting

perl regexp: no match across newlines

Hi. Here's a tricky one (at least to me): I have a file named theFile.txt (UTF-8) that contains the following: a b cWhen I execute perl -pe 's|a.*c|d|sg' theFile.txtin bash 3.2 on MAC OS X 10.6, I get no match, i.e. the result is a b cagain. Any clues why? (2 Replies)
Discussion started by: BatManWSL
2 Replies

8. Shell Programming and Scripting

Retreive string between two chars

I want to write a shell script in order to retreive some data from a log file that i have written into. The string that i want to get is the number 2849 (that is located between | | ). To explain further, this is the result i get after running "grep LOGIN filename.log" but i need to get the... (25 Replies)
Discussion started by: danland
25 Replies

9. Shell Programming and Scripting

regexp to get first line of string

Hi everybody for file in * #Bash performs filename expansion #+ on expressions that globbing recognizes. do output="`grep -n "$1" "$file"`" echo "$file: `expr "$output" : '\(^.*$\)'`" done In the above bash script segment, I try to print just the first line of string named... (3 Replies)
Discussion started by: jonas.gabriel
3 Replies

10. Shell Programming and Scripting

RegExp negative match not working

or I donít know how to make it work Ö Hello im trying to build regexp that will match me single string or function call inside of brackets for example I have : <% myFunction("blah",foo) %> or <% myVar %> and not match : <% if(myFunction("blah",foo)==1) %> or <% while(myvar < 3){... (2 Replies)
Discussion started by: umen
2 Replies

Featured Tech Videos