Re: perl one liner to remove all but the base file name



On Feb 3, 7:34 am, "Oxnard" <oxn...@xxxxxxxxxxxxxxx> wrote:
"Abigail" <abig...@xxxxxxxxxx> wrote in message

news:slrnes536r.ekq.abigail@xxxxxxxxxxxxxxxxxxxxxxx



Oxnard (oxn...@xxxxxxxxxxxxxxx) wrote on MMMMCMIII September MCMXCIII in
<URL:news:45c28416$0$16668$4c368faf@xxxxxxxxxxxxxx>:
&& If I have a file name like:
&&
&& /dkdk888/jdty/file.txt
&&
&& how can I get to just 'file' using a regex. I have come up with
&& or
&& /dkdk/dkdue/dfdf.txt.1234
&&
&& and ending up with 'dfdf'
&&
&& I have come up with 's/^.*\/\([^/]*\)$/\1/' but cannot get rid of the
&& extension. Also I have thought about using basename with the suffix
but the
&& suffix can be different.

s !.*/!!; s !\.[^.]+$!!;

Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
.qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
.qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'

What does the !! do ... I cannot find a reference to it.


The exclamation mark ( ! ) is being used as the delimter in the
regular expression, rather than the slash ( / ). Since there is a
slash in the regular expression, it does have to be escaped since
there is a different delimiter making it somewhat easier to read.
Ken

.



Relevant Pages

  • Re: text processing
    ... i try regular expression i am able to get first two not the third one. ... a word composed of alpha characters ... Now to implement that in pyparsing: ... SLASH = Suppress ...
    (comp.lang.python)
  • Re: Negative Regular Expression
    ... I am trying to write a simple regular expression that returns a match ... string that does not contain specific suffix (e.g. all file names that ... if ($suffix ne 'txt') { ...
    (comp.lang.perl.misc)
  • Regular expression problem
    ... Where all command line parameters start with a forward slash. ... The code I am using to split the string is: ... Regex rex = new ... code through a regular expression test app and that correctly ...
    (microsoft.public.dotnet.languages.csharp)
  • Regexp - matching text not containing certain count of certain characters
    ... I'm trying to build a regular expression. ... One part of it has to match any text not containing a slash except standalone two dots, but I can't find the way to say something like "match any count of any characters except string ..". ...
    (comp.lang.php)
  • Re: Regexp - matching text not containing certain count of certain characters
    ... Regular expression I need has to search through path or URL and find every reference to a parent directory, ... RE is supposed to match /mydir/../ so I can replace it by a single slash and get "definite" URL. ... Now it says "match any string if it doesn't contain a slash" and I need it to say "match any string if it doesn't contain a slash and it is not ..." ...
    (comp.lang.php)