Hello, I was expecting this to be one of the most used cases, but I haven't been able to find anyone else doing it or asking about it.
I would like to replace text using that text. In this specific case, I would like to replace any letter surrounded with square brackets to a lowercased version of the same letter surrounded in triangle brackets (I'm converting BB markup to HTML).
eg. replace [b] with <b> and [I] with <i>. I have tried for 40 minutes but without success, as I cannot obtain the match's content.
Thanks!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you! That works, although I'm not quite sure why, because I can't find \l or this use of $ in the documentation for Python's re class.
Edit: I've been doing some experimenting and was able to use the capitalisation ignore elsewhere too. However, I noticed that the suggested replacement doesn't quite work: [I] becomes <I>. Would it not be possible to let it become <i> automatically? I was intending to use .lower(), but couldn't access the content of the match at all.
Last edit: 607 2021-01-21
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You probably have to go to Boost::Regex documentation to find out all the details of the regex syntax used.
The $ isn't used by itself here. It is part of ${ 1 } which means the first capture group contents.
In my testing of exactly what I provided, [I] becomes <i> so I can't reproduce what you're saying.
You can get good N++/Pythonscript regex help by posting here: https://community.notepad-plus-plus.org/
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello, I was expecting this to be one of the most used cases, but I haven't been able to find anyone else doing it or asking about it.
I would like to replace text using that text. In this specific case, I would like to replace any letter surrounded with square brackets to a lowercased version of the same letter surrounded in triangle brackets (I'm converting BB markup to HTML).
eg. replace
[b]
with<b>
and[I]
with<i>
. I have tried for 40 minutes but without success, as I cannot obtain the match's content.Thanks!
So this is not a Pythonscript question, but search for
(?i)\[([a-z])\]
and replace with
<\l${1}>
Thank you! That works, although I'm not quite sure why, because I can't find \l or this use of $ in the documentation for Python's re class.
Edit: I've been doing some experimenting and was able to use the capitalisation ignore elsewhere too. However, I noticed that the suggested replacement doesn't quite work:
[I]
becomes<I>
. Would it not be possible to let it become<i>
automatically? I was intending to use .lower(), but couldn't access the content of the match at all.Last edit: 607 2021-01-21
You probably have to go to Boost::Regex documentation to find out all the details of the regex syntax used.
The
$
isn't used by itself here. It is part of${
1}
which means the first capture group contents.In my testing of exactly what I provided,
[I]
becomes<i>
so I can't reproduce what you're saying.You can get good N++/Pythonscript regex help by posting here: https://community.notepad-plus-plus.org/