[Israel.pm] (no subject)

Shlomo Yona shlomo at cs.haifa.ac.il
Sun Aug 1 11:07:52 PDT 2004

On Sun, 1 Aug 2004, Ernst, Yehuda wrote:

> I need to find a text inside 2 characters is there a way to do it fast in perl
> example:
> 346kjfh sdf -=-23 we >skjfh87jkfh4389  jkhwe8987<
> i need the txt inside the >  < so the answer will be
> skjfh87jkfh4389  jkhwe8987

	$str='346kjfh sdf -=-23 we >skjfh87jkfh4389  jkhwe8987<';
	($wanted_text) = $str=~/>(.*?)</;

That was for non-greedy matches. If you want greedy matches:

	($wanted_text) = $str=~/>(.*)</;

> also if i want the pattern match to ignore what do i do>
> example :
> sjh 517(lsls-sdff-sdfd-sf  ihee)
> i want to get the text inside the () and i want to ignore  the - and the space

	$str = 'sjh 517(lsls-sdff-sdfd-sf  ihee)';
	($between_brackets)= $str=~/\((.*?)\)/;
	$between_brackets=~s/[\s-]//g; # remove whitespaces and dashes

> last one i need to read a line inside a string do i have a way to do substr until end of line?

Please explain what you want in other words. I coulnd't
understand what you need.

Shlomo Yona
shlomo at cs.haifa.ac.il

More information about the Perl mailing list