Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
G

Graham Nimbley

@Graham Nimbley
About
Posts
105
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • 'Places' dropped from Firefox 2
    G Graham Nimbley

    What the articles fails to mention is that instead of being dropped, Places has been scheduled for inclusion in Firefox 3 for which will begin developing later this year.

    The Lounge html com announcement

  • Asterisk width in css
    G Graham Nimbley

    You are right in saying that * is reserved, but not for autosizing. It used to select all elements in the current DOM. E.g. div * { } will apply styling to all descendant (i.e. children of children, etc) elements of div elements Graham

    Web Development css question

  • The IS operator
    G Graham Nimbley

    Utini wrote:

    why if (control == TextBox) generates an error - can anyone illuminate me?

    Because it's suppose to be: control.GetType()==typeof(TextBox)

    C# help question

  • Regular Expression to convert from PHP to C#
    G Graham Nimbley

    That's okay. That's my alotment of regexs used up for the night! :cool:

    C# csharp php regex help

  • Regular Expression to convert from PHP to C#
    G Graham Nimbley

    They both do the same job. The first it a straight substitution, the second a regex. The first would be marginally faster to perform. Have you read my edit on the harder solution?

    C# csharp php regex help

  • Regular Expression to convert from PHP to C#
    G Graham Nimbley

    The easy way would be to treat the opening and closing tags independently of each other.

    using System;
    using System.Text.RegularExpressions;

    public class Testy
    {
    public static void Main()
    {
    string input="This is a [color=red]red sentence with [color=blue]some blue[/color] words[/color].";

    	// Replace open color tag
    	input=Regex.Replace(input,@"\\\[color=(\[^\\\]\]\*?)\\\]","<color=$1>");
    	
    	// Replace close color tag
    	input=Regex.Replace(input,@"\\\[/color\\\]","</color>");
    	
    	Console.WriteLine(input);
    }
    

    }

    The hard way would involve some complex regexs. Will try to come up with something. Graham. [Edit] Hmmm. It appears that this might be pretty difficult. The problem is that regexs by definition match up by looking forward. To look for nested tags, requires searching the text in tree-wise fashion. To do this in linear text requires requires bilaterial searching, looking forward from the left at the same time looking backwards from the right. Problem is that regexes are virtually impossible to do proper backwards searching. It may be possible to achieve the same effect with some creative code along side regexs. -- modified at 19:13 Monday 26th June, 2006

    C# csharp php regex help

  • Regular Expression to convert from PHP to C#
    G Graham Nimbley

    string regex=@"\[color=([^\]]*?)\](.*?)\[/color\]";
    string replace=@"<color=$1>$2</color>";

    string output=Regex.Replace(input,regex,replace);

    If you are intending to place bbcode for a certain number of tags, it might be easier to use a generic regex. -- modified at 17:58 Monday 26th June, 2006

    C# csharp php regex help

  • Free open source Rich Text Editor
    G Graham Nimbley

    Hi I would recommend TinyMCE[^]

    C# csharp asp-net help

  • Regular Expression to convert from PHP to C#
    G Graham Nimbley

    Hi

    using System;
    using System.Text.RegularExpressions;

    public class Testy
    {
    public static void Main()
    {
    string input="This is a [color=red]red[/color] color and this is a [color=blue]blue[/color] color.";
    string regex=@"\[color=[^\]]*?\](.*?)\[/color\]";

    	string output=Regex.Replace(input,regex,"$1");
    	Console.WriteLine(output);
    }
    

    }

    There was a couple of things wrong with the regex. The original was greedy, and is now lazy. Also some escaping of ']' and '[' was needed. Graham -- modified at 14:41 Monday 26th June, 2006

    C# csharp php regex help

  • Regular Expression to convert from PHP to C#
    G Graham Nimbley

    Good to know. :) Regexs are good fun, but can be a pain in the a**e sometimes!! :rolleyes:

    C# csharp php regex help

  • Regular Expression to convert from PHP to C#
    G Graham Nimbley

    This should be it.

    string regex=@"(.+)\#(.+)\r\n";
    string replace=String.Format("{0}$1{1}$2{2}\r\n","Left","Center","Right");

    string output=Regex.Replace(input,regex,replace);

    I've tweaked the regex as I was having problem with it. I've dumped the code I used to test it:

    using System;
    using System.Text.RegularExpressions;

    public class Testy
    {
    public static void Main()
    {

    string input="bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla.\r\n\r\n"+
    "toto toto toto # toto toto toto\r\n"+
    "toto toto toto # toto toto toto\r\n"+
    "toto toto toto # toto toto toto\r\n"+
    "toto toto toto # toto toto toto\r\n\r\n"+
    "bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla";

    	string regex=@"(.+)\\#(.+)\\r\\n";
    	string replace=String.Format("{0}$1{1}$2{2}\\r\\n","Left","Center","Right");
    
    	string output=Regex.Replace(input,regex,replace);
    	
    	Console.WriteLine(output);
    }
    

    }

    C# csharp php regex help

  • Bit of design advice needed
    G Graham Nimbley

    :confused: Seems a strange move to me. For me, state and zip code are easily represented by string. And creating a wrapper for a primitive type is useless as at some point you will need to interact with the primitive type (in some manner). Classes can't be created without use the new keyword. (Although you can do with reflection) -- modified at 16:22 Sunday 25th June, 2006

    C# csharp design regex xml question

  • bug in HScrollBar control object
    G Graham Nimbley

    This is quoted from MSDN: The value of a scroll bar cannot reach its maximum value through user interaction at run time. The maximum value that can be reached is equal to the Maximum property value minus the LargeChange property value plus 1. The maximum value can only be reached programmatically. So in your case LargeChange=10. You could get round this by adding LargeChange to Maximum; -- modified at 16:12 Sunday 25th June, 2006

    C# help tutorial question workspace

  • picture box - help!!
    G Graham Nimbley

    Hi, I can't see anything wrong with the code above. What control is picture? I'm assuming it's a panel or something. Might be handy to post the code used to gain the list of files.

    C# help graphics tutorial question

  • How is Embedding (.swf) in web pages?
    G Graham Nimbley

    What are you wanting to do? Embed the swf in the webpage or download the swf? If you want to embed the swf, just use the standard object/embed tags. http://www.alistapart.com/articles/flashsatay/[^] details a method embedding swf using XHTML Strict. If you are trying to download the swf, then will you need to change the mime-type of the swf to application/octet-stream

    <%@ Page Language="VB" %>
    Sub Page_Load(sender as Object,e as EventArgs)

    	Dim fileName as String="/test.swf";
    	Response.ContentType="application/octet-stream"
    	Response.AddHeader("Content-Disposition","filename="&fileName)
    	Response.WriteFile(Server.MapPath(fileName))
    
    End Sub
    
    ASP.NET adobe sysadmin help question

  • Regular Expression to convert from PHP to C#
    G Graham Nimbley

    string regex=@"[\r\n]{1,2}(.+)\#(.*)[\r\n]{1,2}";
    string replace=String.Format("{0}\\1{1}\\2{2}\r",myRightVar,myCenterVar,myLeftVar);

    string output=Regex.Replace(input,regex,replace);

    Haven't got VS in front of me, but this (hopefully) should work. Graham. -- modified at 15:34 Sunday 25th June, 2006

    C# csharp php regex help

  • for xml guide
    G Graham Nimbley

    If you just want a general introduction into XML and it's related technologies check out W3Schools.com[^]

    Database csharp database sql-server sysadmin xml

  • Is there any way to display a linked text?
    G Graham Nimbley

    Yes, the control handles the user interaction of the hyperlink for you and renders the text and link both at the same time. It will even change the color of the hyperlink when visited (akin to IE/Firefox and other browsers). Just locate the control as the position you require using .Location

    C# graphics question

  • How can I check if a specific registry entry exists?
    G Graham Nimbley

    How about this. Will check to see if registry key exists.

    using Microsoft.Win32;
    ...
    string keyName=...;
    string valueName=...;
    object defaultValue=...;

    object o=Registry.GetValue(keyName,valueName,defaultValue);

    if (o!=null) {
    // Key does not exist
    }
    else {
    // Do something with key
    }

    C# question windows-admin help

  • Problems in converting colors
    G Graham Nimbley

    Just adding on to what Christian has answered: This should work. (I hope!)

    Color c=Color.FromArgb(int.Parse(hexValue, System.Globalization.NumberStyles.HexNumber));

    [Edit] Yay! It works! :-D -- modified at 18:57 Sunday 18th June, 2006

    C# windows-admin help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups