Page 1 of 1

Help matching a pattern.

Posted: Thu Jun 14, 2007 2:16 am
by Pyrite
Can someone help me for a regex that would find:

Code: Select all

<pre>some text</pre>
But assuming the text between the two tags could be anything, and span multiple lines.

Posted: Thu Jun 14, 2007 4:02 am
by stereofrog
What did you try and what exactly didn't work?

Posted: Thu Jun 14, 2007 4:11 am
by Pyrite
Hmm, I don't have my original script, it's at home. But i think it was something like.

Code: Select all

$pattern = '!<pre>(.*)</pre>!mi';
I'll post more when I get home from work.

Posted: Thu Jun 14, 2007 8:02 am
by feyd
Switch "m" to "s" and add "U" ;)

Posted: Thu Jun 14, 2007 6:21 pm
by Pyrite
One of the things I'm trying to fix is I'm doing a job for a company whose phpdoc is incorrect in tons of files. Check this out:

Code: Select all

//*********************************************
/**
 * function setPrimaryKeyValue
 * <pre>
 * Sets the value of the primary key field.
 * </pre>
 * @param $primaryKey [STRING] new primary key value
 * @return [void]
 */
You'll notice the first line either has to end with a period or have a blank docblock line after it (which it has neither), so since the short description can be up to 3 lines long, it grabs the first 3 lines including the first pre tag and puts that as the short description, and then phpdoc gripes about not closing the pre tag. I need to make some kind of pattern that can find this type of goof up and fix it by putting a blank docblock line after the first line of text.

Any suggestions?

Posted: Thu Jun 14, 2007 6:30 pm
by Pyrite
Aside from that, you might also notice that their @param is used incorrectly. They use it like:

Code: Select all

@param $parameterName [paramType] Description
But I'm pretty sure it is supposed to be:

Code: Select all

@param paramTypeWithoutBrackets $parameterName Description
Does phpdoc really care or does anyone know. How are you supposed to use valid php data types when php doesn't use data types. lol

Posted: Fri Jun 15, 2007 12:56 pm
by Pyrite
feyd wrote:Switch "m" to "s" and add "U" ;)
Thanks feyd, that did the trick! Cheers.

Now I just have to figure out how to make this switcharoo work.