Hi Monks, i'm having a problem coming up with a nice regex for a quick script i'm writing
Essentially i'm parsing a file for certain pieces of information, and contained in the file is a unix path which triggers my regex
probably best explained with simplified code:
my $line=do { local $/=undef; <DATA>; }; my @substrings=$line=~/(\w+\.\w+)/g; print "$_\n" foreach(@substrings); __DATA__ Path to file: /users/me/foo.baz/filename.ext my_content(word.other)
Which obviously gives me:
foo.baz filename.ext word.other
The problem i have is that i'd like to only pick up "word.other"
I've tried: /(?<!\/)(\w+\.\w+) but that just (rightly) gives me "ord.other" and "oo.baz" etc
Obviously i could strip out the paths first etc but it seems like there should be a nice way to do it in a regex, i just can't think of one. Any thoughts? Thanks!
In reply to Regex for ignoring paths by Amblikai
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |