I\'m making a simple Textile parser and am trying to write a regular expression for \"blockquote\" but am having difficulty matching multiple new lines. Example:
My instincts tell me something like...
preg_match("/^bq\. (.+?)\n\n/s", $input, $matches)
Just like the above fella says, the s flag after the / at the end of the RegEx means that the . will match new line characters. Usually, without this, RegExs are kind of a one line thing.
Then the question mark ? after the .+ denotes a non-greedy match so that the .+ won't match as it can; instead it will match the minimum possible, so that the \n\n will match the first available double line.
To what extent are you planning on supporting features of Textile? Because your RegEx can get pretty complicated, as Textile allows things like...
bq.. This is a block quote
This is still a block quote
or...
bq(funky). This is a block quote belonging to the class funky!
bq{color:red;}. Block quote with red text!
All of which your regex-replace technique won't be able to handle, methinks.