2011-12-08 18 views
0

Ok so I'm circling around this site and people are like "OMG, don't use regexp and html!" Well, I just have a custom field in WP that I want to match anything with a simple "a href=" and indicate that it's there.'<a href=' in a string?

I easily get a headache when I start reading about regexp so anyone want to give me a hand?

답변

0

If it's really that simple, you don't need a regex at all. You can do a simple strpos (또는 대소 문자를 구분하지 않으려면 stripos)을 검색하여 문자열에 "a href="이 포함되어 있는지 확인하는 방법.

if(strpos($input, 'a href=') !== false) { 
    // stuff 
}