locked
regular expressions RRS feed

  • Question

  • Sir:

       What is the regular expressions? Why we use?(windows application not web)

      Can U Explain Regular expressions in C# windiws application?

      

     

    Thursday, August 16, 2007 8:38 AM

Answers

  •  

    Google, Exam question Big Smile

     

    etc.

     

    However to me in my words

     

    Regular Expressions are, of course, expressions. They define a string to search for in a larger string. You can then perform actions on the string/s you find.

     

    Hard to explain Smile.

     

     

    But say we have a string. "abcdefg". You can define a regex to look for all "a" and all "e" and either remove all else or remove these entries. regex can get very complicated with expression that identify american phone numbers, can validate input and check it is a valid email or cc number.

     

    You would use them on a Windows app to validate user input or perform complex string replace functions.

    Thursday, August 16, 2007 8:46 AM
  •  

    First read for example http://en.wikipedia.org/wiki/Regular_expression .

     

    In C#-programs, regular expressions are frequently used to validate input data, for example to ensure that a zip code entered by a user actually looks like a zip code, that an e-mail entered looks like an e-mail adress etc.

     

    They are also used to find and extract specific patterns from data,.

     

    Often they are over-used. Regular expressions can easily become overly complex, and tend to be write-only/write-once code, very, very hard to maintain.

     

    Before resorting regular expressions, you should think carefully if this is the right choice.

     

    If you do decide to use regular expressions, check out RegexDesigner.NET at http://www.sellsbrothers.com/tools/#regexd, an invaluable tool to write and test regular expressions.

    Thursday, August 16, 2007 9:00 AM
  • Check out this forum's top announcement post .Net Regex Resource Reference which has referential information geared towards all levels, expert to beginner, where you can find links to tools to use and how-to code examples.
    Thursday, August 16, 2007 6:11 PM
    Moderator

All replies

  •  

    Google, Exam question Big Smile

     

    etc.

     

    However to me in my words

     

    Regular Expressions are, of course, expressions. They define a string to search for in a larger string. You can then perform actions on the string/s you find.

     

    Hard to explain Smile.

     

     

    But say we have a string. "abcdefg". You can define a regex to look for all "a" and all "e" and either remove all else or remove these entries. regex can get very complicated with expression that identify american phone numbers, can validate input and check it is a valid email or cc number.

     

    You would use them on a Windows app to validate user input or perform complex string replace functions.

    Thursday, August 16, 2007 8:46 AM
  •  

    First read for example http://en.wikipedia.org/wiki/Regular_expression .

     

    In C#-programs, regular expressions are frequently used to validate input data, for example to ensure that a zip code entered by a user actually looks like a zip code, that an e-mail entered looks like an e-mail adress etc.

     

    They are also used to find and extract specific patterns from data,.

     

    Often they are over-used. Regular expressions can easily become overly complex, and tend to be write-only/write-once code, very, very hard to maintain.

     

    Before resorting regular expressions, you should think carefully if this is the right choice.

     

    If you do decide to use regular expressions, check out RegexDesigner.NET at http://www.sellsbrothers.com/tools/#regexd, an invaluable tool to write and test regular expressions.

    Thursday, August 16, 2007 9:00 AM
  • Check out this forum's top announcement post .Net Regex Resource Reference which has referential information geared towards all levels, expert to beginner, where you can find links to tools to use and how-to code examples.
    Thursday, August 16, 2007 6:11 PM
    Moderator