[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

if value in value

Posted on 1999-12-16
4
Medium Priority
?
198 Views
Last Modified: 2010-03-05
if $x is "test that" and $y is "test"
how do i say
if ($y is in $x)
in this case $y _is_ in $x
thanks
0
Comment
Question by:boofulls
  • 2
4 Comments
 
LVL 5

Expert Comment

by:thoellri
ID: 2287165
if ($x =~ /$y/)

???
0
 
LVL 85

Expert Comment

by:ozo
ID: 2287206
if( index($x,$y) >= $[ )
0
 
LVL 8

Expert Comment

by:jhurst
ID: 2287879
ozo, what is the advantage in your method?
0
 
LVL 85

Accepted Solution

by:
ozo earned 200 total points
ID: 2289029
It works even if $y contains regular esxpression meta characters (/\Q$y/ would do the same)
it can be faster, since there's no need to compile a regular expression (but you should Benchmark, if you're really concerned about that)
and it demonstrates that there's More Than One Way To Do It.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question