[Gambas-user] Regular expressions
Gianluigi
bagonergi at gmail.com
Thu Dec 30 15:36:47 CET 2021
Il giorno gio 30 dic 2021 alle ore 14:46 Gianluigi <bagonergi at gmail.com> ha
scritto:
>
>
> Il giorno gio 30 dic 2021 alle ore 14:01 Hans Lehmann <hans at gambas-buch.de>
> ha scritto:
>
>> Hello.
>>
>> I am looking for 3 regular pattern expressions that check in a DokuWiki
>> text whether the formats `underlined`, `italic` or `bold` are in the
>> given text.
>>
>> Example text:
>>
>> The //installation// of a **SSH server** on the remote __computer__ is
>> worthwhile in any case!
>>
>> My many attempts ended up with these patterns, which unfortunately do
>> not work:
>>
>> IF sLine Like "*[_]{2}*[_]{2}*" THEN sLine = Replace(sLine, "__", "<uuu>")
>> IF sLine Like "*[*]{2}*[*]{2}*" THEN sLine = Replace(sLine, "**", "<bbb>")
>> IF sLine Like "*[/]{2}*[/]{2}*" THEN sLine = Replace(sLine, "//", "<iii>")
>>
>> Any hint in the right direction will be gladly read.
>>
>> With kind regards
>>
>> Hans
>>
>> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>>
>
> Hi Hans,
>
> Perhaps this can help:
>
> Public Sub Main()
>
> Dim sText As String = "The //installation// of a **SSH server** on the
> remote __computer__ is worthwhile in any case!"
>
> Print Scan(sText, "*//*//*")[1]
> Print Scan(sText, "*__*__*")[1]
> Print Scan(sText, "*{**}*{**}*")[1] ' here i do not understand
>
> End
>
> Regards
> Gianluigi
>
Hi Hans,
this seems to work:
Public Sub Main()
Dim sText As String = "The //installation// of a **SSH server on the
remote __computer__ is worthwhile in any case!"
Dim sItalic, sBold, sUnderline As String
Try sItalic = Scan(sText, "*//*//*")[1]
Try sBold = Scan(sText, "*{**}*{**}*")[1]
Try sUnderline = Scan(sText, "*__*__*")[1]
If sItalic Then sText = Replace(sText, "//", "<iii>")
If sUnderline Then sText = Replace(sText, "__", "<uuu>")
If sBold Then sText = Replace(sText, "**", "<bbb>")
Print sText
End
Regards
Gianluigi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20211230/60ac8c2f/attachment-0001.htm>
More information about the User
mailing list