D
Dave
Hi,
I hope this is the right forum as I am doing this from perl.
I wish to use the search/replace functionality to strip out periods
from a string, but leave the first.
i.e. Change from "this.file.name.is.messy.txt" to "this file name is
messy.txt"
The file extension can be any length or any name.
So far I have tried a few things but my perl/regex knowledge is
something I am only recently building up again. I have looked through
the tutorials but nothing suitable has caught my eye.
I would like to do it in one nicely performing regex if at all
possible.
Things I have tried...
s/\.([^(txt)|^(html)])/ \1/g; # then I realised you cannot have
groupings inside a character class etc.
s/\.(\w+$){0}/ \1/g; # Well the {0} doesn't do what I was hoping for
s/\.(.+\..+)$/ \1/g; # Works if I iterate it externally enough times.
What I would love is something like s/\.(but not where \w+$ matches
here)/ /g; but I am stuck. All I want to know is if I can do this in a
regex oneliner and if so, some clues on where I should be looking
I'd like to work it out myself but am gonna have to ask you guys.
Cheers,
Dave
I hope this is the right forum as I am doing this from perl.
I wish to use the search/replace functionality to strip out periods
from a string, but leave the first.
i.e. Change from "this.file.name.is.messy.txt" to "this file name is
messy.txt"
The file extension can be any length or any name.
So far I have tried a few things but my perl/regex knowledge is
something I am only recently building up again. I have looked through
the tutorials but nothing suitable has caught my eye.
I would like to do it in one nicely performing regex if at all
possible.
Things I have tried...
s/\.([^(txt)|^(html)])/ \1/g; # then I realised you cannot have
groupings inside a character class etc.
s/\.(\w+$){0}/ \1/g; # Well the {0} doesn't do what I was hoping for
s/\.(.+\..+)$/ \1/g; # Works if I iterate it externally enough times.
What I would love is something like s/\.(but not where \w+$ matches
here)/ /g; but I am stuck. All I want to know is if I can do this in a
regex oneliner and if so, some clues on where I should be looking
I'd like to work it out myself but am gonna have to ask you guys.
Cheers,
Dave