.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

Find & Replace - Regular Expressions, what's wrong here?

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


Not really a huge concern, just a minor 'bout of "WTF?".

so [A-Z] matches any 1 character that is between capital a and capital z. 

[^A-Z] is matches any 1 character ths is NOT between captial a and captial z

\ is the escape character for matching literals.

CREATE TABLE X (col1 int, col2 nvarchar(15), test bit) ON primary

Find String:  {(\([^0-9]|,|\)[^,])}

REplace String: \1\n

However the \([^0-9] doesn't find anything in the string.  now frankly, (c seems to match the \([^0-9] because the first literal is a ( and the following character is NOT beween 0 and 9, yet the IDE says with the above set up, 2 matches.  Why? 

I proceed to try and do just "\([A_Z]" and just "\([0-9]" as the find string, and their correlated ^ versions and none of them detected any matches in the file containing that create table statement.  When I remove the \( from the string, it suddenly works.  what up with that?


Jaeden "Sifo Dyas" al'Raec Ruiner


"Never Trust a computer. Your brain is smarter than any micro-chip."
PS - Don't mark answers on other people's questions. There are such things as Vacations and Holidays which may reduce timely activity, and until the person asking

View Complete Post

More Related Resource Links

Web expression 3 and find/replace with a regular expression

I'm am trying to  delete some code in a javascript

<a href="JavaScript:openPopImg('images/Burgess-Rufus1.jpg', 'Rufus Morgan Burgess', '296', '589')">  I want to delete  ', 'xxx', 'xxx')  throughout the web.  I can not get  a regular expression going that will work; .i.e.  ^(\'\, \'[0-9]{3,}\'\, \'[0-9]{3,}\' \)) Am I anywhere near right or is there another way to do this?  Thanks.

Toolbox: Online Scheduling, Jeff Smith's SQL Blog, Easy Regular Expressions, And More


This month Scott looks at improving development skills, writing regular expressions, a web scheduling control and a SQL tips blog.

Scott Mitchell

MSDN Magazine November 2008

SQL Server 2005: Regular Expressions Make Pattern Matching And Data Extraction Easier


Now you can perform efficient, sophisticated text analysis using regular expressions in SQL Server 2005.

David Banister

MSDN Magazine February 2007

Toolbox: Rich Web App UIs, Tools for Regular Expressions, and More


In this issue, create rich Web app UIs, explore tools for regular expressions, and create screen mockups.

Scott Mitchell

MSDN Magazine February 2007

Netting C++: Introducing Regular Expressions


This month Stanley Lippman introduces the support for regular expressions in the .NET Framework.

Stanley B. Lippman

MSDN Magazine November 2006

C++ at Work: Form Validation with Regular Expressions in MFC


I thought I'd use this month's column to describe an interesting app I built using the RegexWrap library described in my article "Wrappers: Use Our ManWrap Library to Get the Best of . NET in Native C++ Code" in this issue.

Paul DiLascia

MSDN Magazine April 2005

Regular Expressions in Filterd Textbox Extender.

Hi... Can we use Regular Expression in Filterd Textbox Extender to match Valid or invalid char. If yes how? Please give me a simplle example... Thank you?

How to get a non-closed tag with regular expressions

Use regular expression to filter following html fragment:<html><img href="***"><b><img href="***" /></html>Expected match result:<img href="***"><b>How to write the pattern? thanks in advance!

Change case using Find & Replace dialog box

Hi, I want to change case of link URLs using Find & Replace dialog box . Is it possible? eg changing http://www.abc.com/S pecial-E dition.aspx, http://www.abc.com/O ther-N ews.aspx to http://www.abc.com/s pecial-e dition.aspx, http://www.abc.com/o ther-n ews.aspx

Find and replace link source

I want to replace links href in the source code using regular expression in Find/Replace dialog box from http://www.abc.com/car-news/13PX5S/News1.aspx, http://www.abc.com/car-news/27JXW5/News2.aspx to http://www.abc.com/car-news/news1/13px5s/, http://www.abc.com/car-news/news2/27jxw5/   - in the resultant URL there will be no Capital letters.    

Combining email and numeric regular expressions

Hi, I am using the following regular expression within an XSD to validate a combination of email ID's and six digit employee ID's separated by a semicolon (;). for example : vedansh.mm@fgfgfg.com;ghgh@ff.com;333333;555555 ^((\s*;?\s*[0-9a-zA-Z_]([-.\w]*[0-9a-zA-Z_])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})+\s*(;\d{6})*)*$ It works for the following vedansh.mm@fgfgfg.com;ghgh@ff.com;333333;555555 but does not work when the six digit number preceeds the email, like below 222333;vedansh.mm@ct.com;ghgh@ff.com;333333;555555;fhfhf@gggg.com or if the input contains only numbers, like 555555 What am I doing wrong. The numbers and email address count may or may not be the same. Thank you for all your help Vedanshu

Patch for VS 2010 Find and Replace Dialog Growing

One of the top reported Microsoft Connect issues with VS 2010 has been an issue with the Find and Replace dialog - which grows 16px each time you use it (which is pretty annoying). The Visual Studio team recently released a patch that fixes this issue. You can download and apply it here. Hope this helps, Scott P.S. A few people reported issues installing the patch if they had an older version of the Silverlight 4 tools installed.  If you see an error message that says you need an update to Visual Studio to support Silverlight 4, you can fix it by installing the latest Silverlight 4 tools release.

Regular expression: Replace anything that isn't alphanumeric with a space?

Hi there,I'm writing a function in C# that will clean up a filename that a user might upload.One of the requirements is to replace any character that isn't alphanumeric with a space, but I can't seem to get the regular expression working to do so?I've include my code below, thanks for any help :)// Replace miscellaneous characters with a space inputFilenameRegex = new Regex(@"^[a-zA-Z0-9]"); inputFilename = inputFilenameRegex.Replace(inputFilename, " ");

find and replace linebreaks in file read from disk

I have a css file which I want to read from disk and in that content I want to find and replace all linebreaks (do I look for vbCrlf or ...?)   Public Shared Function GetFileContents(ByVal FullFilename As String) As String        Dim filecontents As String = ""        If File.Exists(FullFilename) Then            Dim objStreamReader As StreamReader            objStreamReader = File.OpenText(FullFilename)            filecontents = objStreamReader.ReadToEnd()            objStreamReader.Close()        End If       Return filecontents    End FunctionSo in the returned variable "filecontents" I want to find and replace any linebreaks.        FILE: style.css#progress{color:#000;width:500px;height:30px;padding:0px;clear:both;}#progress ul{list-style:none;padding:0px;margin: auto;display:block;}#progress ul li{list-style:none;display:inline;float:left;width:auto;height:30px;padding:0px;line-height:30px; font-family:Arial, Helvetica, sans-serif; font-size:13px;}

Visual Studio 200X (IDE) - Regular Expressions

The regular expressions in Visual Studio 2003/2005/2008 are not the same as .Net Regular Expressions found in code. For that resources check out Regular Expression Resource. If you are reading this you no doubt have questions about Visual Studio's version of Regular Expressions which is totally different from .Net Regular Expressions or any other flavor.The differences between .Net and Studio's version are best summed up here by Jeff Atwood's Coding Horror: Visual Studio IDE and Regular Expression.Of course to do any search or replacing, one will need to use the syntax. That is provided here Regular Expressions Visual Studio.Here are two examples and notes to do a search and replace that I have in my notes which I will share with you. I ran into a situation where I had to refactor text within a few documents. I had never used the Regular expressions in studio during search and replace and decided to learn something new. I had in the text files text that had a pattern like this: return data["COVERAGE_ELECT"] and needed to change each similar occurance to this: return ProcessDataString("COVERAGE_ELECT");Here is the search text I created which specified that the quoted string would be saved into a Visual Studio set (as seen in the {} ) which would create a match that would later be accessed in the replacement text by the Visual Studio replace \1: Visual

Cancel multiple WFs at once & global list find & replace

We have a number of products in our company, and a need for an email alert for various reasons for each product. Thus, I have a SP list where each list item has a drop-dead date, plus the manager's name and manager's email address as well as a note as to what needs to be done. When a new item is created, or a list item is changed, a workflow is initiated. Remember, each single product associated with a manager can have dozens of these email alert list items with differing drop-dead dates. The workflow is designed to send alerts out at stated intervals before the drop-dead date. The problem is that the manager in charge of a given product can and does change. What I have to do now is to open each of the items that pertain to that manager, stop the existing workflow, change the manager's name and email address in the item, then save it (thus starting a new workflow). This can get tedious when a single product can have several dozen list items corresponding to several dozen drop-dead dates. I would like to be able to filter the list, kill all the workflows that are connected to each item in the filtered list, change the manager name and email using the Datasheet facility, then save. At that point, X new workflows would start where X is the number of list items in the filtered list. 1. Is that possible (I doubt it) in our native SP 2007? 2. Does anyone

Construct Regular Expressions

Hi ,  I need to construct a regular expression for the password textbox which shouldn't accept special characters($,@,!,etc).Even whitespaces,tabs. I tried the below this accepts special characters. Any inputs <asp:RegularExpressionValidator ID="RegEx" runat="server" ControlToValidate="Password" ErrorMessage="Password must be atleast 8 characters and include a number,alphabets upper case and lower case. "ToolTip="Password format is not correct" ValidationExpression="^(?=.{8})(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*$"> </asp:RegularExpressionValidator>    Regards  Janet
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