English Wikipedia @ Freddythechick:Reference desk/Archives/Computing/2016 July 27
This template must be substituted. Replace {{Archive header
with {{subst:Archive header
.
|- ! colspan="3" align="center" | Computing desk |- ! width="20%" align="left" | < July 26 ! width="25%" align="center"|<< Jun | July | Aug >> ! width="20%" align="right" |Current desk > |}
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is a transcluded archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
July 27
Some C# help needed
Hi guys! Could somebody help out with C#? If I have regex pattern ([^\.])<ref>.*?<\/ref> (Lorem|Foo)? bar
and string "Foo<ref>Foo</ref> Foo bar
", how to change to lowercase only the second match (in this case - the "Foo", that comes after ref)? If I would need to lowercase everything, I would use something like (tested with other string, so this one may contain some small bugs, but you got the idea):
<syntaxhighlight lang=c#>
string text = @"Foo[1] Foo bar";
string pattern = @"([^\.])Cite error: A <ref>
tag is missing the closing </ref>
(see the help page). Foo bar";
string pattern = @"([^\.])Cite error: A <ref>
tag is missing the closing </ref>
(see the help page). foo bar</nowiki>"). --Edgars2007 (talk/contribs) 12:44, 28 July 2016 (UTC)
- Perhaps this then:<syntaxhighlight lang=c#>
string text = @"Foo[2] Foo bar"; string pattern = @"([^\.]<ref>.*?<\/ref> )(Lorem|Foo)?( bar)"; // captures modified
text = Regex.Replace(text, pattern, delegate(Match match)
{
return match.Groups[1].Value + match.Groups[2].Value.ToLower() + match.Groups[3].Value; // second capture to lower case
});
</syntaxhighlight>Again, not tested. Regex.Replace
replaces all of text
with whatever you return from the delegate()
, right? If you want to keep bits of text
then you need to capture them, modify the captures to suit, reassemble, and return the result. match.Groups[0]
is the raw match; match.Groups[1]
is the first capture, etc.
- —Trappist the monk (talk) 13:24, 28 July 2016 (UTC)
- @Trappist the monk: I thought, that there will be easier solution, but this one works, so thank you! --Edgars2007 (talk/contribs) 17:35, 28 July 2016 (UTC)
- —Trappist the monk (talk) 13:24, 28 July 2016 (UTC)
xwp file
How do I install a .xwp file? Can someone help me please? I collected some clock gadgets a while back from this website. After downloading and opening the WinRar folder, I found a .xwp file - if I re-extract this .xwp file, I find a Widget folder which consisting all the bits. Problem is I still don't know how to install... -- Apostle (talk) 18:12, 27 July 2016 (UTC)
- Your link goes to Google Images and doesn't open any particular image for me. You need to link to the actual web site, not Google Images.
- After 60 seconds of research (googling "xwp gadget") I found XWidget which seems to use .xwp files, so maybe that's what you need. I know nothing about it, though. -- BenRG (talk) 23:27, 28 July 2016 (UTC)