Member Avatar for perlguy

I'm trying to cut off the text leading up to the whitespace past the >.

For example the string is 'Web & Programming > Testing & QA Contractor' and my regex is $job->{'title'} =~ s/^.+>\s+//; I need to end up with just 'Testing & QA Contractor'. Can someone point me in the right direction?

Recommended Answers

All 2 Replies

I'm trying to cut off the text leading up to the whitespace past the >.

For example the string is 'Web & Programming > Testing & QA Contractor' and my regex is $job->{'title'} =~ s/^.+>\s+//; I need to end up with just 'Testing & QA Contractor'. Can someone point me in the right direction?

As you mentioned regex search the maximum quantifiers (greedy), better you will be use the non-greedy matches.

You could use

$job->{'title'} =~ s/^.+?>\s+//;

s/^.+?>\s*//;

I think this is what you are expecting .... even you can use the non-greedy match explained by manimutu for string preceding to '>'

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.