Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

regex true wildcard?

Status
Not open for further replies.

resnak

Technical User
Feb 16, 2005
13
0
0
US
I'm trying to write a perl script to process a database field that keeps the date that a record was saved in an html string preceded by a comment entered by a user at that time. The problem is that the user could possibly enter absolutely any character and I need to write a regular expression that would alow for zero or more of truly any character including a newline character. So far I've got a character class:

[\s\w,'\.\\\{\}\[\]\(\)\^\$\.\|\*\+\?\/-]*

...that, so far, works for the match but I can't believe there isn't a true wildcard that would match absolutely any character making the regular expression less complex. Does anyone know of an easier way to do this?

Justin

Dyslexics of the world: Untie!
 
to match zero or more of any character use '.*', to also match a newline use the "s" operator:

Code:
my $string = "\n";
print "true" if $string =~ /.*/s;
 
That sounds like it would work, and, now that I look back through the perlretut tutorial I can't believe I missed it before. But, I can't really test it until tomorrow. I'll try it and let you know what happens. Thank you for your suggestion!

Justin

Dyslexics of the world: Untie!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top