Posted to tcl by doctaxon at Fri Feb 05 15:20:19 GMT 2016view raw
- set contents {
- {{QS-Medizin|1=Jetzt anders herum [[Benutzer:Partynia|Partynia]] <sup>[[Benutzer Diskussion:Partynia|∞]] [[WP:RM|RM]]</sup> 07:40, 5. Feb. 2016 (CET)}}
- Test nach [[Wikipedia:Redaktion Medizin#Vorlage QS-Medizin]]
- Diese {{Vorlage|Vorlage}} ist eine Vorlage zum Test.}
- #----
- regexp -nocase -- {\{\{QS-Medizin\|(?:1=|2=)??(.*?)\}\}} $contents -- reason
- %puts $reason
- 1=Jetzt anders herum [[Benutzer:Partynia|Partynia]] <sup>[[Benutzer Diskussion:Partynia|∞]] [[WP:RM|RM]]</sup> 07:40, 5. Feb. 2016 (CET)
- ----
- But I added into the regex this: (?:1=|2=)??
- So I guess, that 1= and 2= are not matched in $reason. But the match begins with 1=
- The needed match is (without leading 1=):
- %puts $reason
- Jetzt anders herum [[Benutzer:Partynia|Partynia]] <sup>[[Benutzer Diskussion:Partynia|∞]] [[WP:RM|RM]]</sup> 07:40, 5. Feb. 2016 (CET)
- What is wrong?
Comments
Posted by apn at Fri Feb 05 16:07:47 GMT 2016 [text] [code]
But my point was that (?:1=|2=)? immediately makes the 1= optional and it falls into the (.*) part which is why you see it in reason
Posted by apn at Fri Feb 05 16:10:18 GMT 2016 [text] [code]
% regexp -nocase -- {\{\{QS-Medizin\|(1=|2=){1,1}?(.*)\}\}} $contents x x reason ; set reason Jetzt anders herum [[Benutzer:Partynia|Partynia]] <sup>[[Benutzer Diskussion:Partynia|â]] [[WP:RM|RM]]</sup> 07:40, 5. Feb. 2016 (CET)
Posted by apn at Fri Feb 05 16:12:23 GMT 2016 [text] [code]
Or this % regexp -nocase -- {\{\{QS-Medizin\|(?:1=|2=){1,1}?(.*)\}\}} $contents x reason ; set reason Jetzt anders herum [[Benutzer:Partynia|Partynia]] <sup>[[Benutzer Diskussion:Partynia|â]] [[WP:RM|RM]]</sup> 07:40, 5. Feb. 2016 (CET)
Posted by apn at Fri Feb 05 16:17:57 GMT 2016 [text] [code]
Sorry, my attempts are incorrect
Posted by doctaxon at Fri Feb 05 17:51:56 GMT 2016 [text] [code]
Here the solution with thanks to gifti: regexp -nocase -- {(?:\{\{QS-Medizin\|(?:1=|2=)?(.*?)\}\}){1,1}?} $contents -- reason