Hi guys i have java scripts as follows

His acquaintance with Elizabeth was very trifling.&quot;</p>\n<P class=&quot;Sx0x1&quot;>&quot;To be sure, Lizzy,&quot; said her aunt, &quot;he is not so handsome as Wickham; or, rather, he has not Wickham\'s countenance, for his features are perfectly good. But how came you to tell me that he was so disagreeable?&quot;</p>\n<P>

I changed and replaced everything other than 'Wickham\'s '.The problem here is that when i use regex it only i dentifies ' but not the \ .I dont know if it is because this is a java script .Can anyone help me with this .thanks

I'm not sure what it is you are trying to achieve : /
That isnt Java script..its a segment of html. What are you trying to m,atch with your regex?
Post some code so we can see what you're trying to do

private string processtext(string text)
        {



            string rep2 = "";
            string rep3 = "";
            string rep4 = "";
            text = text.Replace("\'", "''");
            text = text.Replace("’", "'");
            text = text.Replace("'", "''");
            text = Regex.Replace(text, "<(.|\n)*?>", string.Empty);

            text = text.Replace("<", "");
            text = text.Replace(">", "");
            text = text.Replace("&quot;", "");
            text = text.Replace("section_title=", "");
            text = text.Replace("section_txt=", "");
            Match a = Regex.Match(text, "section_title='(?<TITLE>.*)'");
            Match k = Regex.Match(text, "prev=[0-9][0-9]");
            rep3 = k.Groups[0].Value;
            if (rep3 != "")
            {
                text = text.Replace(rep3, "");
            }
            text = text.Replace("prev=", "");
            Match l = Regex.Match(text, "Chapter [0-9][0-9]");
            rep4 = l.Groups[0].Value;
            if (rep4 != "")
            {
                text = text.Replace(rep4, "");
            }
            rep2 = a.Groups[1].Value;
            if (rep2 == "")
            {
                return text;
            }
            else
            {

                text = text.Replace(rep2, "");

                return text;
            }
        }

this code will replace the ' but not \
if you read line number line that line does not do anything for me .If i try to replace just \ it will give me error if i try '\ it wont do anything

Did you try "\\'" ?

As nick indicated (but I'll expand on a bit) if you're trying to match the character '\' you need to write it as '\\'. This is because '\' is considered part of an escape sequence when identifying characters that are otherwise reserved for use within your coding.

For more information on escape sequences check here.

Hope this helps :) Please remember to mark as solved once your issue is resolved.

Edit: Darn you Ryshad you beat me to the edit :P was about to include the @"\'" option then saw your post haha

As well as escaping the escape character as shown above you can use a string literal to prevent the \ being treated as an escape character: @"\'"

\ is a literal for Regex too so it might need to be @"\\'"

thanks guys that helped and how would you get rid of " sign .

More or less same thing applies, " can be written as '\"' or @'"' or if presented in it's alternate form @"&quot;".

Thanks guys .It works fine now

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.