I am new to Perl and trying to use Regex to get a piece of string between two tags that I know will be there in that string. I already tried various answers from stackoverflow but none of them seems to be working for me. Here's my example...
The required data is in $info variable out of which I want to get the useful data
my $info = "random text i do not want\n|BIRTH PLACE=Boston, MA\n|more unwanted random text";
The Useful Data in the above string is Boston, MA
. I removed the newlines from the string by $info =~ s/\n//g;
. Now $info
has this string "random text i do not want|BIRTH PLACE=Boston, MA|more unwanted random text"
. I thought doing this will help me capture the required data easily.
Please help me in getting the required data. I am sure that the data will always be preceded by |BIRTH PLACE=
and succeeded by |
. Everything before and after that is unwanted text. If a question like this is already answered please guide me to it as well. Thanks.