Regex

From Wiki2
Revision as of 11:30, 17 January 2013 by Tim (talk | contribs) (Created page with "==regex== *^[ \t]+ //finds all the space and tabs *[1-9]\. //finds all the line numbers. (replace with #) *[A-E]\. //find A. etc (replace with ##) to clean special characte...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

regex

  • ^[ \t]+ //finds all the space and tabs
  • [1-9]\. //finds all the line numbers. (replace with #)
  • [A-E]\. //find A. etc (replace with ##)

to clean special characters from a string

$clean = preg_replace("/^[^a-z0-9]?(.*?)[^a-z0-9]?$/i", "$1", $text);

sites

expressions

If you want to get'Aloha World'out

Input:

Hello World
Aloha World
Hey There

RegEx:

  \<div\sclass\=\"somename\"\>(?<Text>.*?)\<\/div\>

Yields:

Aloha World (note: In a single group named Text)