Site menu

CodeCook.io

  • Languages
    • C
    • C++
    • CSS
    • Git
    • HTML
    • Java
    • JavaScript
    • jQuery
    • PHP
    • Python
    • Ruby
    • Scala
  • match
  • pattern
  • regular-expression

PHP - Test for expression in string

Find match of a particular regular expression in a string.

Regular expression
Subject string
Match found code block
No match code block
0
357
  • Share on Facebook
  • Share on Google+
  • Share on Twitter

Using preg_match

Perform a regular expression match. documentation

if(preg_match({{pattern}}), {{string}}) {
    {{match_code}}
} else {
    {{no_match_code}}
}
php

Notes

last update: Nov. 14, 2014

Advertisement

This project is hosted on DigitalOcean, try it and support us

Other language

  • Java
  • Python
  • JavaScript
  • Ruby

Random task

  • List all git stash entries
  • Single comment
  • Resolve merge conflict with local file
  • Counter loop
  • Drop all git stash entries
  • Blog
  • About
  • License