"(?!\()([A-Z][a-z]+)(?!\))"
"MkObjectLogC"
"(?:Mk)?(?:Object)?(?:Log)?C"
set match "MkObjectLogC"
while {[regsub {(?!\()([A-Z][a-z]+)(?!\))} $match {(?:\1)?} match]} {}
"(?:Mk)?(?:(?:(?:(?:(?:Ob)?j)?e)?c)?t)?(?:(?:Lo)?g)?C"
https://regex101.com/r/cWJrDK/1
using the code
set match "MkObjectLogC"
while {[regsub {(?!\()([A-Z][a-z]+)(?!\))} $match {(?:\1)?} match]} {}
but the solution is:
"(?:Mk)?(?:(?:(?:(?:(?:Ob)?j)?e)?c)?t)?(?:(?:Lo)?g)?C"
the online regexp is ok:
That's because you repeatedly reprocess the result of the previous >substitution. The online regexp does the processing in one go. If you do
the same with regsub, you get the requested result:
regsub -all {(?!\()([A-Z][a-z]+)(?!\))} $match {(?:\1)?} match
That's because you repeatedly reprocess the result of the previous
substitution. The online regexp does the processing in one go. If you do
the same with regsub, you get the requested result:
regsub -all {(?!\()([A-Z][a-z]+)(?!\))} $match {(?:\1)?} match
Why are the (?!\() bits necessary?
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 715 |
| Nodes: | 16 (0 / 16) |
| Uptime: | 162:34:53 |
| Calls: | 12,095 |
| Calls today: | 3 |
| Files: | 15,000 |
| Messages: | 6,517,780 |