Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

regex blackout 1

Status
Not open for further replies.

MoshiachNow

IS-IT--Management
Feb 6, 2002
1,851
IL
Hi,

Why the following never becomes true ?

if ($name =~ /$key/) {

Values:

$name="Intel[R] PRO_1000 MT Network Connection _2 - Packet Scheduler Miniport"
$key="Intel[R] PRO_1000 MT Network Connection _2"

thanks

Long live king Moshiach !
 
/\Q$key\E/

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Yes,
The \Q tells Regex engine to treat the special characters ([ and ] in this case) as regular characters and \E tells to stop treating it.

So [ and ] are treated as regualr charactes instead of character class declaration in regex.

--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top