Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 20th, 2013, 12:42 PM
abhibitu abhibitu is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 2 abhibitu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 4 sec
Reputation Power: 0
Perl Programing

TRMMMYQ128F932D901<SEP>SOQMMHC12AB0180CB8<SEP>Faster ***** cat<SEP>Silent Night

TRMMMKD128F425225D<SEP>SOVFVAK12A8C1350D9<SEP>Karkkiautomaatti<SEP>Tanssi vaan

TRMMMRX128F93187D9<SEP>SOGTUKN12AB017F4F1<SEP>Hudson Mohawke<SEP>No One Could Ever

TRMMMCH128F425532C<SEP>SOBNYVR12A8C13558C<SEP>Yerba Brava<SEP>Si Vos Querés

TRMMMWA128F426B589<SEP>SOHSBXH12A8C13B0DF<SEP>Der Mystic<SEP>Tangle Of Aspens

what would be the regular expression to take out just the last part of the above sentences?

how should i remove the special characters in those extracted part?

and how should i convert them to lower case letters?

Reply With Quote
  #2  
Old February 20th, 2013, 02:06 PM
Laurent_R Laurent_R is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2012
Posts: 506 Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 4 Days 19 h 4 m 21 sec
Reputation Power: 385
Hi,

a starting point:

Code:
my $value = $1 if $line =~/<SEP>(\w+)$/;
$value = lc $value;
$value =~tr/àéèùçôê/aeeucoe/;


You will probably want to beef up the tr// substitution list, this is just an example.

Reply With Quote
  #3  
Old February 20th, 2013, 02:12 PM
abhibitu abhibitu is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 2 abhibitu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 4 sec
Reputation Power: 0
Quote:
Originally Posted by Laurent_R
Hi,

a starting point:

Code:
my $value = $1 if $line =~/<SEP>(\w+)$/;
$value = lc $value;
$value =~tr/àéèùçôê/aeeucoe/;


You will probably want to beef up the tr// substitution list, this is just an example.



so if i want to remove special characters like (,[{,',@ how will the expression be like?

Reply With Quote
  #4  
Old February 21st, 2013, 02:33 AM
Laurent_R Laurent_R is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2012
Posts: 506 Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 4 Days 19 h 4 m 21 sec
Reputation Power: 385
Add the /d modifier to the tr/// command. Charaécters havinf no substitutes un ther substitution list will be removed. For example:

$value =~tr/àéèùçôê;%/aeeucoe/d;

Here, the ";" and the "%" will be removed from the string, while other letters will be replaced by their respective substitutes.

Reply With Quote
  #5  
Old February 21st, 2013, 05:48 AM
ishnid's Avatar
ishnid ishnid is offline
kill 9, $$;
Dev Shed God 4th Plane (6500 - 6999 posts)
 
Join Date: Sep 2001
Location: Shanghai, An tSín
Posts: 6,894 ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level) 
Time spent in forums: 4 Months 2 Weeks 1 Day 22 h 36 m 34 sec
Reputation Power: 3885
Quote:
Originally Posted by abhibitu
so if i want to remove special characters like (,[{,',@ how will the expression be like?

The definition of a "special character" is usually far more complex than you might expect (since there is a huge number of characters to consider). It's often easier to identify characters that you want to keep, and then remove those that are not in that set of desired characters.

You can use the /c switch on tr/// to complement the search list (i.e. replace any characters that AREN'T in the search list). For example, to remove any non-alphanumeric characters in a string called $str you could use this:
Code:
$str =~ tr/a-zA-Z0-9//cd;
Comments on this post
Laurent_R agrees!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Perl Programing

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap