isolating text in a string



Hi,

I'm trying to isolate text in a string. My string is typically of the
form:
sometext["moretext",

I would like to isolate moretext.

I tried:
#!/usr/bin/perl -w
my $string = 'sometext["moretext",';
print $string;
my $snippet;
($snippet, $snippet) = split(/$string/,\[,2);
print "$snippet\n";

I don't seem to be able to escape the [ in the split function, so two
questions:
1. How do I escape the [?
2. What would be a better way to approach this problem?

Thanks,
Tim Bowden

.



Relevant Pages

  • Re: isolating text in a string
    ... I'm trying to isolate text in a string. ... I would like to isolate moretext. ... my $snippet; ... use warnings; ...
    (perl.beginners)
  • Re: Unrecognized escape sequences in string literals
    ... If you don't know what your string literals are, ... Adding escape codes into the string literal doesn't change this ... extra effort required to defeat the compiler (forcing the programmer to ... And if you saw that in Python, you'd also know that there are some ...
    (comp.lang.python)
  • Re: Unrecognized escape sequences in string literals
    ... need worry that I've misinterpreted what a string literal means. ... You can't expect the compiler to save you from ... Adding escape codes into the string literal doesn't ... (This behavior is useful when debugging: if an escape sequence is ...
    (comp.lang.python)
  • Re: problems with opening files due to files path
    ... GUI or it is a console app. ... of what an escape character and escape sequence is. ... character) inside a string specially, it makes the character after the ...
    (comp.lang.python)
  • Re: Unrecognized escape sequences in string literals
    ... if he could just look at the string literal and know. ... friend is a programmer. ... If you don't know what a backslash escape is going to do, ... That's an enormous difference from Python, ...
    (comp.lang.python)