.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

How to find misspelled words with regex

Posted By:      Posted Date: August 28, 2010    Points: 0   Category :.NET Framework
Hi all I need a RegEx that will find a specific word within a long string. The issue is that this word may be misspelled and I need to find it even so. I would like to accept a certain percentage of wrong-ness when looking for the word. Ex. The complete string: Hello, this is my comp/et string to look at The word to search for: complete Let's say that I which to accept a maximum of two wrong letters in the above string, then the RegEx should match the word complete. However, if I only accept 1 wrong letter it shouldn't find it. Ideally the RegEx would also be able to handle whitespaces, and missing letters. Ex: The complete string: Hello, this is my com plee string to look at The word to search for: complete This should match the word as well, even though there is a whitespace between 'm' and 'p' and the letter 'l' is missing. Is this possible at all with RegEx or should I be looking at an alternative way to solve it? Thanks, Tommy

View Complete Post

More Related Resource Links

REGEX does not match when line ends with the characters.. also, how to negate words that contain the

\S*(ai|ie)\S*   seems to match all words with characters ai and ie in them.  However it does not match if the line ends with them, how can fix that?Also, how can I match all words that DO NOT contain those characters.. I've tried ?! and [^ to no avail.Thanks in advance for any help or information!

Find text between two separate words - to parse text from a message

Hi all, I am new to regular expressions.   The following text has got three sections; - Name, Date, and Message   [Sender]: John Smith  [Received]: 2005-8-21 3:28:9Hi bob, thanks for the message[Sender]: Paul Stein  [Received]: 2005-8-21 3:17:38Cannot make that time...[Sender]: Sarah S  [Received]: 2005-8-20 15:18:2No way! Let me know if it's on. I would love to see that film. It got great reviews.[Sender]: John Smith  [Received]: 2005-8-21 3:28:9Hi bob, thanks for the message[Sender]: Paul Stein  [Received]: 2005-8-21 3:17:38Cannot make that time...[Sender]: Sarah S  [Received]: 2005-8-20 15:18:2No way! Let me know if it's on.   I want to extract each of them.   The text between "[Sender]:" and  "[Received]:" is the NAME   The next word after the  "[Received]:"  is the DATE   The MESSAGE starts after the digits of the Date end and it is upto the mark  "[Sender]:"   Can anyone tell me how to extract it using C# Regular expressions.   Thank you for your time.   Tomy

Regex to find nested list items

Hi everyone,

I am trying to write a regex parser that will extract links from some html that is generated within our services. Now, extracting items in html I am able to do, but I have n idea how to parse the links from the following, and keep the structure, e.g with the following menu

<ul id="menu">

What I have tried is

<ul id=\"menu\"[^>]*>(.*)</ul>

Now, this does get me the whole menu, but then If I do:


I can get the menu items, BUT, I lose the structure.

So I thought I would be able to extract the LI that contain the UL inside it, but the problem is that using the regex above to extract that LI, I retrieve the following:


Can anyone suggest a way that I can use regex to retrieve this keeping the same structure? or another way of processing these menus and being able to record the structure?



Programatically Find and Replace the words in Word documents in SP Doc library

The client has uploaded 1000 of MS Word document in SP Document Library.
We have to change some specific text in all documents which we upload in a Sp Document Library.
We have to do this without opening a document.(i.e) we have to do find and replace a text programatically.
Please provide me the solution.
Rajanikanth Rayala

How to Find a specific sentence in a table that contains only words?


Hello dear grurus,

I don´t know if my question did, somehow, explain itself... if not, let me brake it down:

I have a table like this:

ID         WORDS

1          change color red

2          open door

3          find terms


now, I would like to search for an ID giving this search string: "Whould you like to change the color to red, please?"

please notice I have given a sentence containing 3 keywords found in row 1 for the table above... I know this, but how do I make t-sql to know this? 


Thank you so much for the help guys!

PS: please let me know if im not clear enough.

Find ISBN 10 or ISBN 13 substring RegEx.Match


Hi, i am trying to find an ISBN substring:

Regex regex = new Regex(@"ISBN(-1(?:(0)|3))?:?\x20+(?(1)(?(2)(?:(?=.{13}$)\d{1,5}([ -])\d{1,7}\3\d{1,6}\3(?:\d|x)$)|(?:(?=.{17}$)97(?:8|9)([ -])\d{1,5}\4\d{1,7}\4\d{1,6}\4\d$))|(?(.{13}$)(?:\d{1,5}([ -])\d{1,7}\5\d{1,6}\5(?:\d|x)$)|(?:(?=.{17}$)97(?:8|9)([ -])\d{1,5}\6\d{1,7}\6\d{1,6}\6\d$)))");

Match m = regex.Match("one two ISBN-13: 978-0-470-04673-9 three");

I got the regex from regexlib.com and understand it should match either on a 10 or 13 digit ISBN. Unfortunatly match always returns false.

I would also like it to be able to find the ISBN even if there are no spaces either side, i.e. "one twoISBN-13: 978-0-470-04673-9three" if that is possible.

So far not working, will take another look tomorrow (is 3am now!) but in the meantime if anyone has any pointers would be muchh appreciated.



Using RegEx, how to find substrings enclosed by a special character


Let’s say, special character is: $

Input string: This $abc$ and $def123$ is a test

Desired output:




I tried: @“\$.*?\$"


Got the output as:



find a Control inside a GridView using jQuery


I have databound GridView in my page and I have a hidden DIV in all rows. Each row contains a Button that I want it to make the DIV visible for me! how can I use that with jQuery?!

here is the code page: 

<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" 
                                EnableModelValidation="True" GridLines="None" ShowHeader="False" Width="100%">

Is there any way to find out the reason for session expiry?


Dear All,

is there any way to find out the reason for session expiry?



Cannot find ASP.NET tab on IIS6+2003,how to choose .NET framework 4.0?


Hi all,

I just wanna setup a .net framework 4.0 on my VPS for a new site. While I could not find the ASP.NET tab on properties. I did some research find some similar problems but haven't fixed it yet.

Any suggestion would helpful.



Using loginName to find ADInfo from an outside class



I wrote a class to pull adinfo and for the life of me I can't seem to figure

out why it says "Invalid Login Name" no matter what I type in. If I leave

it blank it seems to work properly but it doesn't seem to be actually searching

the AD. I'll drop the whole class here, it's being initiated by a button click

on an outside form.


Thanks in Advance for any help Offered,



Imports System.DirectoryServices
Imports Microsoft.VisualBasic
Imports System.String
Imports System.Collections
Imports System.Security.Principal
Imports System.Security.Permissions

Namespace LoginButton
    Public Class LoginButton

        'Class Variables
        Dim UserID As String = Nothing
        Dim DomainDN As String = ConfigurationManager.AppSettings("myConnectionString")
        Dim ADEntry As DirectoryEntry = New DirectoryEntry(DomainDN)
        Dim objSearch As New System.DirectoryServices.DirectorySearcher(ADEntry)
        Dim oResults As DirectoryServices.SearchResultCollection
        Dim oResult As DirectoryServices.SearchResult
        Dim RetArray As New Hashtable
        Dim page As Page = DirectCast(HttpContext.Current.Handler, Page)
        Dim TextLogin = DirectCast(page.FindControl("

LDAP - Can't find server


Hey people,

I would like to get a persons name from their username - a common query on forums i know, but i haven't managed to get mine working yet and any help would be appreciated.

I currently have this code that I found here: http://www.vbforums.com/showthread.php?t=612655 (Thanks Chris128)

I have adapted it from VB into VB.net. The page renders but when i enter my username into the Username textBox and hit the submit button (Which calls IsUser) I just get "The specified domain either does not exist or could not be contacted." I have tried lots of other code but I always get this response...

If anyone can help by posting links to a tutorial or another post for code that they know works, i will give it a go.


Imports System.DirectoryServices

Partial Class UserInfo
    Inherits System.Web.UI.Page

    Private Function GetRealNameFromAd(ByVal UsernameToFind As String) As String
        Using searcher As New DirectorySearcher(New DirectoryEntry())
            searcher.PageSize = 1000
            searcher.SearchScope = SearchScope.Subtree
            searcher.Filter = "(&(samAccountType=805306368)(sAMAccountName=" & UsernameToFind & "))"
            Using Results A

Count words in the ascx file



I have 163 .resx files. I want to count the words in these files, because my want to translate the sentences (my task is the localisation).

Now I'm opening each file in Ms Visual Studio and I count words manually. How can I count words in all files? And the second question: can I use a program what grab strings from .resx into an editor where I can translate them and save bacn into .resx files? Or must open the files one by one and edit the text fields manually?

Thanks for helping, unfortunately I'm not a programmer.

Could not find default endpoint element that references contract 'CurrencyProxy.CurrencyServiceSoap



I created 2 projects in my solution:

  1. Classic asp.net web service (asmx)
  2. Class library project which references service
  3. web site project which references class library project
  4. Windows app project which references service.

Both projects were created in 3.5 framework and in Visual Studio 2008 Beta 2.

I added web service reference to Class library project. When it asked for namespace I typed "CurrencyProxy". Projects build ok, but when I run web app, Class library throws an error: Could not find default endpoint element that references contract 'CurrencyProxy.CurrencyServiceSoap' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.

I believe it has something to do with app.config in Class library project. Here is part from app.config:

<binding name="CurrencyServiceSoap" closeTimeout=

Asp to asp.net cant find Msxml2.XMLHTTP


Hi all i have this following code in asp and when i try this in .net it asks me to run in aspcompat=true mode which i dont want.
So i tried to DIM x as Msxml2.XMLHTTP but its not defined any suggestions on this. Thanks

xmlhttp = Server.CreateObject("Msxml2.XMLHTTP")
        On Error Resume Next
        xmlhttp.Open("POST", "https://xxxxx.cgi", False)
        xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
        queryString = "xxxRequestMode=X&xxxRequestData=" & Server.UrlEncode(xmlStr)


Regex pattern for validating IPv6


Can anyone can make a regular expression pattern for validating IPv6 (not IPv4)?

Ipv6 has many formats and aliases. I tried making the pattern but written in a lot of codes (i'm not sure my code below will be 100% accepting valid formats and 100% declines invalid formats).


Cant find vsi file for CSS Friendly Control Adapters


Hi guys

This is driving me crazy... I cant find the .vsi file for installing the CSS Friendly Control Adapters Project. Does anyone know where I can get this?

The following link: http://www.asp.net/cssadapters/ only leads to the CodePlex wiki where I can download the dll and a partial solution. Essentially, I'm looking for the source code to implement the Menu adapter.

Any help is much appreciated!

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