I need to get rid of the first fifteen charcters
(which are uppercase letters and numbers) of a line. How
would I do this using regular expressions.
I know that something like this would work,
but would only get rid of the first character.
s/[^A-Z0-9]//
Any help would be appreciated
Thanks.
Kauser
------
s/^.\{15\}//
--
Barry Margolin, bar...@genuity.net
Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
> Subject: Regular expression question
Regular expressions are a wide subject. Conder putting more info in
you subject line. To make space you should omit the word "question".
> Newsgroups: comp.unix.questions,comp.lang.perl.misc
What does this have to do with Unix?
> I need to get rid of the first fifteen charcters
> (which are uppercase letters and numbers) of a line. How
> would I do this using regular expressions.
>
> I know that something like this would work,
> but would only get rid of the first character.
>
> s/[^A-Z0-9]//
No, it would get rid of the first character that was not a
upperalphanumeric.
s/^[A-Z0-9]{15}//;
Of course if you know that the first 15 characters will always be
upperalphanumeric then you can simply use substr().
> Any help would be appreciated
Perl regular expressions are documented in the perlre manpage.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
S/^.{15}//
"man regexp" for a complete description of REs.
s/^.{15}//;
--
Garry Williams
^ ^
$ sed 's/^.\{15\}//'
---Robert
>s/^.\{15\}//
That is an understandable mistake, if you use more other regexp packages
(like sed/grep/awk/lex, or search tools inside text editors) than Perl.
Perl has the meaning of '\{' vs. '{', and of '\(' and '(', reversed
compared to many of those other packages. For example, simple grep uses
'\(' for grouping, while egrep uses '('.
(source: "Mastering Regular Expressions", Jeffrey Friedl)
--
Bart.
I read the message in comp.unix.questions and didn't notice that it was
x-posted to comp.lang.perl.misc, so I answered in a sed/grep frame of mind.