Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Regex help

by jwkrahn (Monsignor)
on Dec 11, 2012 at 11:29 UTC ( #1008274=note: print w/replies, xml ) Need Help??


in reply to Regex help

my $str = '-plastic-Protector/dp/B00074658'; $str =~ s!.*/dp/!!; print "$str\n";

Replies are listed 'Best First'.
Re^2: Regex help
by perlnoobster (Sexton) on Dec 11, 2012 at 11:34 UTC
    Thank you everyone, all methods worked great :) I do have one slight niggle though, If the string contains the value AA1X32ALFC60JT8 then can this entire row including the /dp be excluded? e.g can -plastic-protector-AA1X32ALFC60JT8/dp/B00074658 be removed from the results? Thank you :)

      See the specific grep-map code in my other answer. For this requirement, you would simply add a negative match to the grep block:

      my @ids = grep { defined $_ && $_ !~ m{AA1X32ALFC60JT8} } map { match_ +id($_) } @lines_from_file;

      Bye
       PetaMem
          All Perl:   MT, NLP, NLU

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1008274]
help
Chatterbox?
[Corion]: Meh. I have a very simple mechanism to scrape+track prices, and even to send me mail if something changes (via cron), but SQLite doesn't support window functions, so my simple SQL to determine a price change won't work :-( Maybe I should store the DB ...
[Corion]: ... in Pg, but that would mean that I'd have to deal with credentials and stuff :)
[Corion]: In fact, the whole thing is just four simple programs, one App::scrape, another being DBIx::RunSQL, and one some glue to convert a JSON object into an SQL INSERT statement (+DBI connect/execute), so it would be an incredibly simple solution...
[Corion]: ... but that simplicity falls down due to SQLite letting me down and me being too lazy to move to a real DB. Maybe DBD::CSV can handle window functions...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (10)
As of 2018-02-23 15:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (302 votes). Check out past polls.

    Notices?