[pmwiki-users] Regex help (excluding spaces)
Brian Tibbels
brian.tibbels at clickmarlow.co.uk
Sat Mar 9 17:57:53 CST 2013
LOL @ petko :)
*
*
On 9 March 2013 21:40, Petko Yotov <5ko at 5ko.fr> wrote:
> Eric Forgeot writes:
>
>> Markup ('txt2tags_bold', 'directives', '/\*\*(.*?)\*\*/', "'''$1'''");
>>
>> It works but I get wrong output when having for example **this and
>> **this, because this kind of text is not supposed to be marked as bold.
>> (**this and** should be bold on the other hand)
>>
>> So I modified my rule this way, to exclude white spaces before or after:
>>
>> Markup ('txt2tags_bold' , 'directives',
>> '/\*\*[^\s](.*?)[^\s]\*\*/' , "'''$1'''");
>>
>> Now it almost works, **this and **this are not catched, but the bold
>> parts are not correct, the first and last letters are striped out, for
>> example **another** would become nothe (in bold). Do you know why, and how
>> to correct this?
>>
>
> You need to place the parentheses around everything that is meant to be
> bold, for example '/\*\*([^\s].*?[^\s])\*\*/' .
>
> However, this will not allow you a single bold character. This one will:
>
> '/\\*\\*(\\S(.*?\\S)?)\\*\\*/'
>
> This means :
> - starts with a '**'
> - opening the first matched pattern (
> - then a non-whitespace-character \\S, same as [^\\s]
> - opening a second pattern (
> - .* anything, ending with a non-whitespace-character \\S
> - closing the second pattern )
> - the ? after the ) means the pattern is optional
> - closing the first matching pattern )
> - once again '**'.
>
> This is fun :-)
>
> Petko
>
>
>
> ______________________________**_________________
> pmwiki-users mailing list
> pmwiki-users at pmichaud.com
> http://www.pmichaud.com/**mailman/listinfo/pmwiki-users<http://www.pmichaud.com/mailman/listinfo/pmwiki-users>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.pmichaud.com/pipermail/pmwiki-users/attachments/20130309/ea294ace/attachment.html>
More information about the pmwiki-users
mailing list