Stoppt die Vorratsdatenspeicherung! Jetzt klicken &handeln! Willst du auch an der Aktion teilnehmen? Hier findest du alle relevanten Infos und Materialien:

Archived entries for regexp

Mal wieder Reguläre Ausdrücke

Ich mag Reguläre Ausdrücke und in dem Posting Advanced Regular Expression Tips and Techniques gab es auch einige Dinge die ich nicht mehr auf dem Schirm hatte.

(?(condition)true-pattern|false-pattern) or (?(condition)true-pattern)
For example we can use this to check for opening and closing angle brackets:
$pattern = '/^(<)?[a-z]+(?(1)>)$/';

In the example above, ‘1′ refers to the subpattern (<), which is also optional since it is followed by a question mark. Only if that condition is true, it matches for a closing bracket.

‘non-capturing’ Subpatterns:

preg_match('/(?:H.*) (f.*)(b.*)/', 'Hello foobar', $matches);

By adding ‘?:’ at the beginning of the subpattern, we no longer capture it in the $matches array.

Reguläre Ausdrücke für die Webentwicklung

Reguläre Ausdrücke sind so eine wundervolle Erfindung, cats who code stellt einige praktische Vertreter für die Webentwicklung vor.

Validate an URL

/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \?=.-]*)*\/?$/

Grab unclosed img tags

<img([^>]+)(\s*[^\/])>

Find all CSS attributes

\s(?[a-zA-Z-]+)\s[:]{1}\s*(?[a-zA-Z0-9\s.#]+)[;]{1}

Regular Expression Editor

Weil Reguläre Ausdrücke so ungemein praktisch sind: rubular

Rubular is a Ruby-based regular expression editor. It’s a handy way to test regular expressions as you write them.

Reguläre Ausdrücke für Webentwickler

Jean-Baptiste Jung stellt 15, naja 14 denn ein Beispiel ist ein str_replace(), reguläre Ausdrücke vor die für Webentwickler spannend sein könnten wie z.B: Get all images from a HTML document, Matching a XML/HTML tag oder Parsing Apache logs.

Advanced Regular Expressions

Karthik Viswanathan erklärt im smashing Magazine einige fortgeschrittene Konzepte von Regulären Ausdrücken.

Und weil Reguläre Ausdrücke etwas so feines sind sei das hier verlinkt.



Copyright © 2004–2009. All rights reserved. – Impressum

RSS Feed. This blog is proudly powered by Wordpress and uses Modern Clix, a theme by Rodrigo Galindez.