#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2008
    Posts
    85
    Rep Power
    7

    Pasre sign between quotes


    g'day everybody.
    I've got few lines, for example
    Code:
    set = str("\nUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
    set = str("User-Agent: Mozilla/4.0", "(compatible; MSIE 6.0; Windows NT 5.0)");
    And I need rexexp value so as to take it from array in perl...
    $_[0] =~ s/....../
    I just need take value between " "(quotes)
    currently I use perl.
  2. #2
  3. No Profile Picture
    User 165270
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2005
    Posts
    497
    Rep Power
    938
    It is not clear to me what you want to do exactly.
    How can your "few lines" look like? The first just has one pair of quotes in it, while the second has two pairs of quotes.
    Are you processing the in put line by line or are your two examples stored in one string?
    Have you already tried something yourself? If so, could you post that as well: that way you might learn from your mistakes if someone points out the error in your code.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    May 2007
    Posts
    765
    Rep Power
    929
    Using Perl, the easiest way would be to use Text::Balanced (which comes with perl) or Regexp::Common to do the dirty work for you.
    sub{*{$::{$_}}{CODE}==$_[0]&& print for(%:: )}->(\&Meh);
  6. #4
  7. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2008
    Posts
    85
    Rep Power
    7
    yes, i use Text::Balanced within any string parse, but I don't simply which to do it very fun work. It two strings I might take from <stdin> my script from any input char and I want take all value between quotes from everyone string to variable. I can read any other lines very well, but on that lines I stand confused. So, which to pass quotes and have got text between quotes per string in variable?
  8. #5
  9. Salaryman
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Location
    St. Louis, MO
    Posts
    341
    Rep Power
    71

    Thumbs up


    Originally Posted by umbrella
    I just need take value between " "(quotes)
    currently I use perl.
    Code:
    if ($subject =~ m/(?<=").*(?=")/i) {
    	# Successful match
    	
    	# show whats between quotes
    	print $0; 
    } else {
    	# Match attempt failed
    }
  10. #6
  11. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2008
    Posts
    85
    Rep Power
    7
    thanks for reply, but it doesn't work...
    Code:
    # echo 'set = str("\nUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");' | perl -e 'while(<>){$_ =~ m/(?<=").*(?=")/i;print $_;}'
    set = str("\nUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
    I'm anticipate something like on it..
    "\nUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"

IMN logo majestic logo threadwatch logo seochat tools logo