ReplaceAll() method removing the wrong characters!

hi all,
im new to java and im having a problem with the following replaceAll() method:
content = content.replaceAll("[^a-zA-Z0-9]", " ");What I want it to do is replace all punctuation with a whitespace, which works fine! However, the program deals with french texts and this regular expression removes words with accents on, such as ?, ?, ?,?, etc.
Does any one know how i can get rid of all punctuation, but keep accented words?
thanks alot,
Torre

torre1501 wrote:
hi all,
im new to java and im having a problem with the following replaceAll() method:
content = content.replaceAll("[^a-zA-Z0-9]", " ");What I want it to do is replace all punctuation with a whitespace, which works fine! However, the program deals with french texts and this regular expression removes words with accents on, such as ?, ?, ?,?, etc.
Does any one know how i can get rid of all punctuation, but keep accented words?
thanks alot,
TorreWell, a-z is just those 26 letters, without any mention of accepted characters.
Try \p{Punct}, the POSIX character class for one of !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~

Similar Messages

  • Removing the Control Characters from a text file

    Hi,
    I am using the java.util.regex.* package to removing the control characters from a text file. I got below programming from the java.sun site.
    I am able to successfully compile the file and the when I try to run the file I got the error as
    ------------------------------------------------------------------------D:\Debi\datamigration>java Control
    Exception in thread "main" java.util.regex.PatternSyntaxException: Illegal repet
    ition
    {cntrl}
    at java.util.regex.Pattern.error(Pattern.java:1472)
    at java.util.regex.Pattern.closure(Pattern.java:2473)
    at java.util.regex.Pattern.sequence(Pattern.java:1597)
    at java.util.regex.Pattern.expr(Pattern.java:1489)
    at java.util.regex.Pattern.compile(Pattern.java:1257)
    at java.util.regex.Pattern.<init>(Pattern.java:1013)
    at java.util.regex.Pattern.compile(Pattern.java:760)
    at Control.main(Control.java:24)
    Please help me on this issue.
    Thanks&Regards
    Debi
    import java.util.regex.*;
    import java.io.*;
    public class Control {
    public static void main(String[] args)
    throws Exception {
    //Create a file object with the file name
    //in the argument:
    File fin = new File("fileName1");
    File fout = new File("fileName2");
    //Open and input and output stream
    FileInputStream fis =
    new FileInputStream(fin);
    FileOutputStream fos =
    new FileOutputStream(fout);
    BufferedReader in = new BufferedReader(
    new InputStreamReader(fis));
    BufferedWriter out = new BufferedWriter(
    new OutputStreamWriter(fos));
         // The pattern matches control characters
    Pattern p = Pattern.compile("{cntrl}");
    Matcher m = p.matcher("");
    String aLine = null;
    while((aLine = in.readLine()) != null) {
    m.reset(aLine);
    //Replaces control characters with an empty
    //string.
    String result = m.replaceAll("");
    out.write(result);
    out.newLine();
    in.close();
    out.close();

    Hi,
    I used the code below with the \p, but I didn't able to complie the file. It gave me an
    D:\Debi\datamigration>javac Control.java
    Control.java:24: illegal escape character
    Pattern p = Pattern.compile("\p{cntrl}");
    ^
    1 error
    Please help me on this issue.
    Thanks&Regards
    Debi
    // The pattern matches control characters
    Pattern p = Pattern.compile("\p{cntrl}");
    Matcher m = p.matcher("");
    String aLine = null;

  • I need help to remove the wrong email on my Iphone.  I can't down load app because my apple ID doese not match with the wrong email please help

    I need help to remove the wrong email on my Iphone.  the represnter who set up my phone put in the wrong email, and now I can't down loand apps on my phone because the apple ID does not match

    So sign out of the Apple ID under Settings > iTunes & App Store, then sign in with your own.

  • How to escape or remove the special characters in the xml element by regula

    Hi members,
    How to escape or remove the special characters in the xml element by regular expression  in java??
    For Example ,
    <my:name> aaaa </my:name>
    <my:age> 27 </my:age>
    In the above example , i have to retrieve the value of the <my:name> Element(For examlpe -- i have to get "aaaa" from <my:name> tag)...
    How to retreive this value by using DOM with XPATH in java
    Thanks in Advance

    Hi members,
    I forget to paste my coding for the above question....This is my coding......In this display the error...... Pls reply ASAP.......
    PROGRAM:
    import java.io.IOException;
    import java.util.Hashtable;
    import java.util.Map;
    import org.w3c.dom.*;
    import org.xml.sax.SAXException;
    import javax.xml.parsers.*;
    import javax.xml.xpath.*;
    public class DOMReaderForXMP {
         static Document doc;
         static XPath xpath;
         static Object result;
         static NodeList nodes;
         public DOMReaderForXMP() throws ParserConfigurationException, SAXException,
                   IOException, XPathExpressionException {
              DocumentBuilderFactory domFactory = DocumentBuilderFactory
                        .newInstance();
              domFactory.setNamespaceAware(true);
              DocumentBuilder builder = domFactory.newDocumentBuilder();
              doc = builder.parse("d:\\XMP.xml");
              XPathFactory factory = XPathFactory.newInstance();
              xpath = factory.newXPath();
         public static void perform(String path) throws Exception {
              result = xpath.evaluate(path, doc, XPathConstants.NODESET);
              nodes = (NodeList) result;
         public void check() throws Exception {
              perform("//my:name/text()");
              if (!nodes.item(0).getNodeValue().equals("application/pdf")) {
                   System.out.println("Mathces....!");
    ERROR:
    Exception in thread "main" net.sf.saxon.trans.StaticError: XPath syntax error at char 9 in {/my:name}:
    Prefix aas has not been declared

  • How to  remove the Special characters like @,#,$ ,..from field

    How to  remove the Special characters like @,#,$<,..from text  field. we nedd to remove any specila char from text field .
    ex:text  = just#fi%cation@text
    the text should be justification.

    hi check this ..
    data:char(25) value '5#4#2#&1#&',
         char1(9) .
           replace all occurrences of '#' in char with 'and' .
           replace all occurrences of '&' in char with 'num' .
         write: char.
    or use this..
    data:char(25) value 'test@ing*5#4#2#&1#&',
         char1(9) .
           replace all occurrences of '#' in char with space .
           replace all occurrences of '&' in char with space .
           replace all occurrences of '@' in char with space .
           replace all occurrences of '*' in char with space .
         write: char.
    regards,
    venkat.

  • HT2534 But now , the hole process of sign uping is changed , please remove the wrong guide its not working , and why apple not let to access the free app .!!!

    But now , the hole process of sign uping is changed , please remove the wrong guide its not working , and why apple not let to access the free app .!!!

    Try going to https//appleid.apple.com, click Manage my Apple ID and sign in with your current iCloud ID.  Tap edit next to the primary email account, tap Edit, change it back to your old email address and save the change.  Then edit the name of the account to change it back to your old email address.  You can now use your current password to turn off Find My iPhone on your device, even though it prompts you for the password for your old account ID. Then go to Settings>iCloud, tap Delete Account and choose Delete from My iDevice when prompted (your iCloud data will still be in iCloud).  Next, go back to https//appleid.apple.com and change your primary email address and iCloud ID name back to the way it was.  Now you can go to Settings>iCloud and sign in with your current iCloud ID and password.

  • Keyboard Typing The Wrong Characters

    My keyboard was working fine and then it start to type the  wrong characters, eg, when I hit the "0" I get "/"  My computer is a Lenovo G530 MT 4446
    How can I fix this? Please help!

    hello,pls try this out
    1.format the system completely  and instore new operating system
    2.if the problem still persist,try using external keyboard and check if d same problem still occure.
    thanks

  • My wireless keyboard is typing the wrong characters?

    My wireless keyboard is typing the wrong characters and as a result I cannot log into my profile and check the system preferences?

    sgompf wrote:
    My wireless keyboard has the wrong characters mapped to the number keys;
    That mapping is determined by the settings of your computer.  Go to system prefs/keyboard/input sources and make sure that only US is present on the list (or whatever language you normally use).

  • How can i remove the special characters from my keyboard on my iphone3gs

    how can i remove the special character from my keybord keys on my iphone 3gs

    What characters are you talking about exactly and why would you want to remove any?
    There is really no way to modify Apple's keyboards or add your own in iOS, but there are some apps that may provide a work around.

  • Removing the special characters...

    Hi All,
    I have a small problem.
    In one of my city table we have values like this as shown below
    Moscow - My'tisch'inskaya/1-st, 21
    Which contains single quotes in it. is it possible to remove the single quote using a query.
    There are more than 3000 records in the table which makes very difficult to remove manually. DB is oracle 10g
    thanks in advance
    baskar k

    Hi,
    There are some many methods do that..
    SQL&gt; select replace(c1,'''','') from t4;
    REPLACE(C1,'''','')
    &lt;HR&gt;
    Moscow - Mytischinskaya/1-st, 21
    SQL&gt; select translate(c1,'''',' ') from t4;
    TRANSLATE(C1,'''','')
    &lt;HR&gt;
    Moscow - My tisch inskaya/1-st, 21
    SQL&gt; Update t4
    2 set c1 = translate(c1,'''',' ') ;
    1 row updated.
    SQL&gt; select * from t4;
    C1
    &lt;HR&gt;
    Moscow - My tisch inskaya/1-st, 21
    * Pavan Kumar N

  • Methods returning the wrong values...

    Hi,
    I've managed to get my hands on vb6 (though, it would be really nice if there was vb .net support.. I thougt this was coming in 1.5?) and have run into a rather odd problem. get Methods seem to return values from the wrong methods! For example, let's pretend my activex control stores values about a person. getName would return their age, while getAge might return null! Something is also going wrong with my method that accepts input and returns a value (okay, it is a money conversion program!)... it is returning null!
    I have verified that all these methods work perfectly by running the code in JBuilder with a Main class.
    Any idea what to do?
    (or how to make it work in .net!!!)
    Thanks!

    Wow!! I think the key was using the CreateObject command. I was adding it as a control, like I would a textbox. Things are working perfectly as far as I can tell! I wonder how I am supposed to test it in the vb6 testbox then.. Hrm.. Odd.
    This is great, though!! Thanks so much. :)

  • Help with remove.Instance function removing the wrong row

    Hi there,
    I have been working on Livecycle forms for about two weeks now and have been able to work out quite a bit of what I need to do.  However, I am really hoping someone can help me with a two problems that I cannot seem to solve. 
    The first one is; if I click on the 'remove a row' function on my form and it is the only row, it comes up with an error message,  How do I stop that from being displayed?  I think I need to use the IF function with >1 but cannot seem to get it to work.
    Secondly, if for example I add two rows using the +row button to make three rows and in rows 1&2 I input some data.  If I then want to delete row 3 and press the -Row button it deletes row number 2 and the data in that row and leaves row number 3.  How can I change it so that when I delete a row it deletes row number three and leaves row number 2.  essentially, I need it to delete rows from the bottom up and not from the top down.  Hope this makes sense.  Any help would be greatly appreciated!
    Attached is a link to my form.
    https://copy.com/RiktBtj0uiSA
    Thank you.

    Hi there,
    When removing instances within an object's event which is inside the instance, you must make sure that you remove this particular instance at the end of the event.
    E.g.:
    If you remove the instance of which the button is inside before even finishing the whole event, the program will not recognize what event is to be finished because you have removed the object's which is fired..
    So here you are trying to finish some code which doesn't exist anymore ...
    I suggest you should always remove the instance of (this) object at the end of any event to make sure to finish all your actions before deleting the object.
    Hope this help!

  • How to remove the EOF characters 0d & 0a from the unix file

    Hi,
             We have a requirement in which the EOF (End of file) characters 0d & 0a needs to be removed from  the Unix file generated by an ABAP program. Any pointers/solutions will be highly appreciated.
    Regards,
    Anil

    UNix files do not have a 0d and 0a end of line, they only have 0a as line terminator.
    In general, unix files do not have a end of file character (^Z).
    If you do not want to have several lines, dont write several lines, write all in one line using a string variable.

  • Equium L20 - keyboard creates the wrong characters

    Hi there.
    my keyboard is not making the right buttons. everytime i press 'u' it comes up with 4. i = 5, o = 6, p = -, and so on and so forth. the onlyway i can remove this is by holding down the Fn button inbetween Ctrl and Alt. how can i take this keyboard lock off for good?
    feel free to email [email protected]
    thanks for your time.
    xxx

    Hi
    I agree with Sam and Jack. If you watch carefully the keyboard you will notice the keyboard has a small numeric block and all symbols are grey and placed at the bottom sloped keys side.
    Like the guys already said you can enable or disable this numeric block using FN+F11 key combination.

  • ID is displaying the wrong characters

    Hi,
    I am running ID CS2 on an xp machine (SP2 - to open ancient PM files) and have been setting in text recently for the 28 EU languages, I have the Baltic ones left to do, and have come up with a slight problem!
    When opening the text in Word I can see all the characters correctly, (i's with lines over instead of dots) and other Baltic characters.
    When pasting into InDesign they turn into other characters (the i mentioned above now has a hat on ^ instead.)
    And ideas how this happens and how to correct it?
    I open the same INDD file on the Remote (windows server 2003) to work on it at home and they are all correct.
    I've reloaded the Myriad pro font and deleted Adobefnt.lst files but nothing has happened.
    I've looked through all the settings and they are identical on the remote and my machine so I don't understand why my machine is a little strange.
    I hope someone understands this and can help me as the remote is very slow!!
    Justine

    Please don't hijack a mostly unrelated thread. New topics should be started on their own.
    That said, this sounds like you are running Windows XP SP3 or Vista, both of which break the ability of CS2 to open PM documents. Your only choice, if that is your situation and you need to open these, is to either find a system running SP2 or roll back, or to upgrade to a current version of InDesign.
    Peter

Maybe you are looking for

  • IPhone 6 package lost in transit?

    I ordered an iPhone 6 that was scheduled to arrive last Friday, and it is Wednesday now and the package still has not arrived. I called Apple and they put a tracer on the lost package to start an investigation but they said there is nothing else they

  • External hard drive via ethernet ok?

    I've been looking for an external hard drive to attach to my g4 450mhz tower (yeah, it's eight years old this month). I need to download files (photographs, illustrator files, and indesign files), fonts, etc. from my computer and bring them with me t

  • How do I get rid of the trial version of Adobe Acrobat XI Pro?

    I downloaded the trial version of Adobe Acrobat XI Pro, and now my trial is over.  I can no longer view any .pdf files on my computer--every time I download a .pdf file it just takes me to this site and tries to get me to buy the product.  I tried to

  • Finding a character in a string

    I have a RomanNumber class and an now trying to write a Calculator class. Im not sure how to go through the users input string to decide which operator they are using. VI + I VI - I I was using indexOf() but when I use that I can only pass in one ope

  • How to Loop the Import of Excel Worksheets

    The following code goes to SharePoint, downloads a worksheet from the SharePoint, copies the worksheet to an existing workbook, then renames the downloaded worksheet. Public Sub ImportFileName()    ' Define Workbook and Worksheet Variables    Dim wkb