Reputation: 251
I want to match strings containing alphanumeric, non alphanumeric characters (simple punctuation marks including underscores, hyphens and decimal points) and spaces in my input file and then print them to a separate file.
Here's an example of the string:
ID123 MIR24-2 10.6
I can search for individual items in the string but nothing that ties the whole lot together including the spaces.
I've tried:
/^[a-zA-Z0-9]*[A-Za-z0-9_-]*[-0-9.0-9]*$/
Upvotes: 0
Views: 201
Reputation: 91498
Not sure I understand well your needs, but is this regex work for you?
$str =~ /\w+\s[\w-]+\s\d+\.\d+/;
Upvotes: 1
Reputation: 3153
Try regex something like this /^[\w+\d\s-]+$/i
.
Are there any patterns like it'll contain at least 1 space etc.?
Upvotes: 0