regexp: match string that contains list of chars

Tags
beginners

 

 
Thread Tools Search this Thread
# 8  
Old 10-14-2010
Quote:
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  
Old 10-14-2010
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  
Old 10-16-2010
#deleted#

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

Ruby
Code:
>> 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

 

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
sed - print only the chars that match a given set in a string naderra Shell Programming and Scripting 1 08-25-2018 12:54 PM
sed to remove newline chars based on pattern mis-match chill3chee Shell Programming and Scripting 6 07-08-2016 01:02 AM
find and Replace String in Perl - Regexp cillmor Shell Programming and Scripting 2 10-31-2015 01:10 PM
Add an string at every x chars kadu Shell Programming and Scripting 9 12-06-2014 10:27 AM
How to search for a string with special chars? santokal UNIX for Dummies Questions & Answers 8 02-19-2014 06:37 PM
Regexp for string that might contain a given character jnojr Shell Programming and Scripting 1 08-30-2013 04:09 PM
How to use regexp to find an ipaddress from a query string? ampak Shell Programming and Scripting 3 04-22-2013 08:59 PM
Question on TCL regexp and match mar85 Shell Programming and Scripting 2 12-05-2012 04:09 AM
[Solved] print chars of a string tafazzi87 Shell Programming and Scripting 10 11-03-2011 07:45 AM
Repeatable chars in a string BeefStu Shell Programming and Scripting 3 10-04-2010 02:46 AM
extract string until regexp from backside elifchen Shell Programming and Scripting 8 05-26-2010 09:20 AM
perl regexp: no match across newlines BatManWSL Shell Programming and Scripting 2 05-17-2010 03:19 AM
Retreive string between two chars danland Shell Programming and Scripting 25 06-25-2007 04:02 PM
regexp to get first line of string jonas.gabriel Shell Programming and Scripting 3 05-09-2007 04:46 AM
RegExp negative match not working umen Shell Programming and Scripting 2 08-22-2006 05:57 PM