.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Regex to ignore some string(s)

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :WPF

I'm trying to write a regular expression to read all of the source code files that I have in some directory. These files will look like:

*.cs, *.xaml.cs,*.cpp, *.c, *.h

What I have so far is  @"^.+\.(c(s)?(pp)?|h)" which I think is working. I would like to be able to also ignore certain file names like "AssemblyInfo.cs" and "assemblyInfo.cs".

How do I go about this?




View Complete Post

More Related Resource Links

Split string using Regex with escape sequences

What is the regex to split a string using the delimiter ';', but not split on '\;' ? Backslash would be my escape character in my split string, so finding '\;' would not split, but '\\;' would split. For example I want a regex that would split the following:     "aaa;bb;cccc\;dd\;eee\\;ff\\;ggg\\\;hhh" into the following string array:     aaa     bb     ccc\;dd\;eee\\     ff\\     ggg\\\;hhh   Thanks!   -Sylvain

RegEx Request - Extract an tag from string...

Hello, Can anyone give me a regular expression that will extract the <img> tag from a string.  I am receiving descriptions from an rss feed and the description contains an <img> tag in the text.  I want to extract the <img> so that I can display it in a different location on my page. I have fooled with some regular expressions, but my knowledge of them is not very good. Thanks in advance for any help!!

Extract String using RegEx

HelloI have below data in string format in a field in table and would like to parse the name from the quantity. The name should be anything before it hits a numeric numberin below example CHLORPHENIRAMINE is the name. i really appreciate if i can get a regex to extract the name from below string                                    "CHLORPHENIRAMINE 8MG CAP SA",                                    "CHLORPHENIRAMINE 12MG CP SA",                                     "CHLORPHENIRAMINE 4MG TABLET",                                     "CLEMASTINE FUM 2.68MG TAB",             &n

Replace space from string - REGEX.



I have some problem with RegEx.

I have text:

"something here [tagQuote=Name of Author]bla bla bla[/tagQuote] something here"

And now I want to replace all the whitespace character in quote attribute with "%#%#%#%".

So I want to have: [tagQuote=Name%#%#%#%of%#%#%#%Author]bla bla bla[/tagQuote]

So remove all of the whitespaces between "[tagQuote=" and "]...[/tagQuote]"

regex ignore


Hi i have a method that removes all html tags which works.. i would like to ignore any <br /> or <br> tags how would i create a ignore list?

protected string RemoveHtmlCode(string strHTML)
            Regex objRegExp = new Regex("<(.|\\n)+?>");

            //Replace all HTML tag matches with the empty string
            string strOutput = objRegExp.Replace(strHTML, "");

            return strOutput;

Regex solution to ID Excel Cell references in an Excel Formula string


Is there a RegEex solution to accomplish the following:

- Assuming Operator Pattern is "[/*^&()=<>,+-]"
- Cell References are pre-fixed Post-fixed by an Operator (including a comma)
- Cell References Start with Alpha Characters without-interruption - by an operator
    then Followed by numerics-without-interruption - by an operator

----------------------FORMULA STRING INPUT----------------| |---OUTPUT---|
                                                                                        Cell    Cell
1) =I82*I83/365*0.11      <  <  <  <  <  <  <  <  <  <  <  < >  I82     I83
2) =IF(H84>H80*0.91,H84,0.91*H80) <  <  <  <  <  <  <  < >&nbs

RegEx: converting email address to mailto link in a string using VB



i have tried various ways to accomplish this, but to no avail.  I don't know how to generate the replacement text (mailto link) so I just used a bunch of x's until I can figure it out.  Here is what I have (which currently not replacing emails in string):

Here is my Code behind:

        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load, Me.Load


            Me.lblText.Text = DAL.PortLog.PortLogs.PortLogToHTML(Me.TransitID)
        End Sub

Here is the called function to replace email addresses:

    Public Shared Function ConvertEmailToMailToLinks(ByVal textToConvert As String) As String

        Dim pattern As String = "\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b"
        Dim input As String = textToconvert
        Dim replacement As String = "xxxxxxxxxXXXXxxxxx"  'test
        Dim rgx As New Regex(pattern)
        Dim result As String = rgx.Replace(input, replacement)

        Return result

    End Function

Here is the DAL code:

Splitting string using RegEx



I have following string

string str = '1,2,23;33;33,4;66;77"

i want to split it like




Means if ; is coming after comma then i dont want the spilt.

Split will occur only if , is followed by , otherwise if , is followed by ;is should not be split.

How to go about it?


PL suggest.




chandan mahajan

does static Regex.Match(string input, string pattern, RegexOptions ops) cache ?


in msdn, it is said that static Regex.Match(string input, string pattern) caches for future uses,

but it doesn't say whether static Regex.Match(string input, string pattern, RegexOptions ops) caches.

Then does it cache? Does it help to promote performance at creation?


How to Encrypt Query String Parameters in ASP.NET

Encrypt Query String Parameters in ASP.NET.u can send secure data one page another page u can also use query string to encrypt

Connestion string create any database server

This links important to how to create connection string to any data base sever.

SQL Connection String

We can learn or know how can we connect the database from our .net. This will help for freshers or .NET beginners!

Built-in Functions - String Functions

String functions let you extract various portions of character strings, change the case of strings, concatenate and reverse strings and perform many other types of manipulations. All built-in string functions are deterministic with the exception of CHARINDEX and PATINDEX

abstract away the source of the connection string using a class with a static property.

ASP.NET provides a configuration system we can use to keep our applications flexible at runtime. In this article we will examine some tips and best practices for using the configuration system for the best results.

The element of a web.config file is a place to store connection strings, server names, file paths, and other miscellaneous settings needed by an application to perform work. The items inside appSettings are items that need to be configurable depending upon the environment, for instance, any database connection strings will change as you move your application from a testing and staging server into production.

Let's abstract away the source of the connection string using a class with a static property.

highlight string


i am looking for a function that takes two string parameters 

str1 = "hello how are you today mr john"

str2 = "how today"

and in return it shoud highlight the words "how" and "today".

Any ides? I prefer if its possible using reg expression...Thanks

Could some one tell me whats the Problem with this String Manipulation ??? C#.net



I store some values from code behind to a label which is Hidden !

<asp:Label ID="lbl_Hidden" runat="server" Visible = "false"></asp:Label>

and at the page load event i retrieve the value of the label & assign it to a string !

stringvalue = lbl_Hidden.Text;

Now i dont know why this manipulation does'nt work !

I've a character 'A' in the string and i'm unable to replace it with a space !

stringvalue.Replace(A, " ");

Wot do u think abt it ????

extract picture data from a string


dears,advance thanks.can anybdy help to solve my problem which is describing below.

Example- %%D1,100,0,0004[data...][0d0a]

Head - %%D1
Amount of data package -100
The data package No. - 0
Data Length -1024 (0004 (low bit in front, high bit in back) 0004= 0x0400=1024;)

data- Original Picture data -1024(maximum)
Tail -0x0d0a
Data in hex

from the above example i want to extract picture data and need to store in to the sql table.sql table columname is image and datatype is also image.after that i wanted to display this image column to an aspx page.

expecting help asap.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend