Java regular expression

Hello

Can you help me how to replace all the commad located on a string between double quotes 2?

for example, I have a text file that contains data such as as follows

A, "-16,12","178,245", "-15,506"

B, "-16,12","178,245", "-15,506"

C, 0, 0.1

I need a result like this:

A, "-16.12", "-178.245", "-15.506".

B, "-16.12", "-178.245", "-15.506".

C, 0, 0.1

I did this, but without the regular expression. It seems to me that a regular expression, it is more elegant to parse each line and replace it.

Thank you

in which case you can be sure that all the change always are enclosed in doublequotes the regex would be like this:

line.replaceAll("(\"-?\\d*),(\\d*\")","$1.$2");

Good bye

DPT

Tags: Java

Similar Questions

  • Set-search-data-hiding-rule-prop-dn-regular-expressions setting targets

    Hello. I'm trying to put in place a masking rule 6.3 DPS data. I want to have the data masking rule apply to any DN that ends with o = ny, c = us. I tried to adjust the target-dn-regular-expressions to ' o = ny, c = us$ '. I thought that if DPS used regular expression match, the $ at the end should serve as an anchor for this channel. But the rule is not fired. I proved it by assigning the expression regular votes to zero and then the target dns to exactly match the dn I'm back. Anyone know what I need to put in the phrase correspond to what I want? Thank you

    Hello

    Regular expressions must comply with the Java regular expression specificationa, available on [http://download.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html]

    For example, the regular expression (. *) c = us, o = ny filters out all o = ny, c = us tree.

    Hope this helps

    Sylvain

  • regular expression format?

    My question hopefully get me flamed, but I have to ask. When adding regular expressions newspaper Pattern Match in a configuration property is as the regular expected perl or java as expression format?

    for example, in a box, I entered \bStack_Trace\b/. simply the meaning match any pattern bordered by Stack_Trace?

    do I need... / / game characters or make just hack away and hyperic will add the rest?
    or
    do I need to get stuff like this myString.matches("\bStack_Trace\b")

    Thanks in advance,

    Deeboh

    Sure you can't get flamed for something not well documented nor frequent ;)
    It's just a small wrapper around java.util.pattern:
    http://svn.Hyperic.org/branches/HQ_3_0/src/org/Hyperic/HQ/product/StringMatcher.Java?root=Hyperic+HQ&view=markup

    We should probably add a main() method here for easy test, but you can test log_track from the command line like so:

    ./JRE/bin/Java-Dplugins.include=system - Dlog debug = - Dlog_track.debug = true.
    -jar pdk/lib/hq-product.jar t 'File server file' m - one track log.
    -End = log/test.log '-Dservice.log_track.pattern=\bStack_Trace\b'

    Then another term:
    echo "this is a Stack_Trace for deeboh" > log/test.log (will be)
    echo "this is a HayStack_Trace for dougm" > log/test.log (will not match)

  • How to add regular expressions in viewobject bind variable

    Hello

    Java class is used to set the bind variable adf

    vm.setWhereClause ("name =: fname");
    vm.defineNamedWhereClauseParam ("Pnom", null, null);
    vm.setNamedWhereClauseParam ("fname", "Alana");

    It works great and it returns Alana

    But what I want is to define a regular expression when he returned all the names that start with A.

    I tried with this.

    vm.setNamedWhereClauseParam("fname","A*");

    also

    vm.setNamedWhereClauseParam("fname","A%"); "

    but the two did not work.

    Help, please.

    Thank you
    Hari

    What is

         vm.setWhereClause("FIRST_NAME LIKE :fname||'%'");
         vm.defineNamedWhereClauseParam("fname", null, null);
         vm.setNamedWhereClauseParam("fname","A");
    

    aRUN-

  • Chain problem: not being able to escape a bracket for a possible regular expression

    So, I have barely any idea of how to use regular expressions except a little knowledge of it in PHP.

    What I'm trying to do is to separate the first part of a string of qualifier, so I need a regular expression since ideally I wish I could. The problem I have is that my attempt of separation does not work. I tried to do what I think the model or class Matcher, I tried to use String.split, and I tried using the regular String.replace method. What I'm trying to do is illustrated (I hope) in the following NBS:
    public class SSCCE
    {
        public static void main(final String args[])
        {
            final String testString = "I want to keep this sentence. (I wish to "+
                "discard this sentence and the space in between the sentences.)";
            final String testExtract = testString.replace(" \(.+\)","");
            System.out.println(testExtract);
        }
    }
    From my understanding, the parentheses are supposed to be a wild card of sorts, so they would need to be escaped in order to be taken as a literal, which means that line 7 is supposed to correspond to any of the characters inside the brackets where the opening is preceded by a space and then delete them. The problem I have is that escaping brackets generates an error and does not escape their product the original string. So I don't know how to tell Java I use actually literal parentheses.

    I tried to configure my preferences of error to ignore everything, but it does not work.

    I don't know if it's important, but I use Java 1.6 and Eclipse for PHP 1.3.2.20110218 - 0812.

    rp0428 wrote:
    Shouldn't be using replaceAll if you use a regular expression?

    http://docs.Oracle.com/javase/6/docs/API/Java/lang/string.html

    and, on the assumption that you actually use a replaceAll(), you need to escape to the '-' characters as they are themselves i.e. Java escape characters

    " \\(.+\\)"
    

    In addition, the use of ".". +"can lead lead to important feedback. In this simple example you probably won't notice it, but in general, you'd better avoid the return back by using the reluctant modifier or by replacing the '.' by a character set that does not include the character terminal.

  • Regular expression TO validate the name of column

    Hi all

    I want to write a regular expression to validate the name of column names.i.e enterted must follow the convention of valid column name
    contain only A - Z, a-z, 0-9, _, $, and #.

    Please someone help me to do this.
    Padma

    Hey padma.

    Regular expression TO validate the name of column

    to set jaspx for example in the Validation number:

    **

    If your use na na... chain mention you model as etc. from A to z...

    otherwise if the two method nt answer using java Scrpit na... it's better ground for you.

    If however hepatitis is any querys na msg me... If possible I try best,.

    Thnks,
    Suresh V

    Published by: V Suresh on April 2, 2012 16:55

  • Ampersand in regular Expression

    I am trying to match an ampersand, but have not been able to find a way to do it, even after searching the forum and the wider Internet through Google. I understand that a double ampersand is used as an intersection operator in regular expressions, but my understanding is that sign should be considered as a literal. I'm under JDK 1.6.0 update 25 on platform Linux x 64 (build 1.6.0_25 - b06). The following is an example of my sentence:
    $ cat Test.java 
    public class Test
    {
        public static void main(String[] args)
        {
            System.out.println("select &hi from dual".matches("&"));
            System.out.println("select &hi from dual".matches("\u0026"));
            System.out.println("select &hi from dual".matches("\\&"));
            System.out.println("select &hi from dual".matches("&&"));
        }
    }
    $ javac Test.java
    $ java Test
    false
    false
    false
    false
    $ 
    How can I match it?

    Note that

    "abc".matches("b")
    

    Returns false.

    Read the docs for Matcher.matches () If you don't know why.

  • Help... Regular expression for characters [special] /: ^ & * () @# $

    Regular expression to parse the string in square brackets:
    I am trying to parse a string in square brackets, but as [] are special characters used in regular expressions to start a character class, I want to remove its special meaning. This regular expression **_user=[a-zA-Z]*@[a-zA-Z]{2}+.abc.com_** works for the analysis of [email protected]* but I want to analyze _user = [[email protected]] _ *, I use the term regular *user=\[[a-zA-Z]*@[a-zA-Z]{2}+.abc.com\]*_* but is in error because it makes special sense of character class. I tried to use \ backslash before *------[]] * but it not working giving error * "INVALID ESCAPE SEQUENCE."

    [JAVA CODE: user = "user=\[[a-zA-Z]*@[a-zA-Z]{2}+.abc.com\"];
    Pat pattern is Pattern.compile (user);.
    Carpet to match = pat.matcher ("2011-03-11 02:08:44, 653: User = [[email protected]], Doing report: account.server.regprocmemunix.daily");
    If (mat.find ()) {}
    User1 = mat.group ();
    }
    This room code gives error _ _ "SEQUENCE EXHAUST" INVALID and throw a PatternSyntaxException*.

    Please help me parse the string within large brackets [].

    You realize that, although ' [' is a special character in a regular expression, ' \' is a special character in Java, right?] You also need to escape to the ' \'.

    So, if you want to use ' [' in your regular expression, you must use something in the sense of]

    \\[
    

    Published by: almightywiz on April 25, 2011 14:05

    DOH... too slow...

  • what regular expression

    I have a problem with a regular expression. The goal is to find each word that does not begin with a capital letter. I don't know how to use regex. So far, I have this:
    [a-z]+
    but which cuts the first letter (capital) and also returns these hyphenated words. I appreciate all help.

    PR.

    Aardenon wrote:
    I have a problem with a regular expression. The goal is to find each word that does not begin with a capital letter. I don't know how to use regex. So far, I have this:

    [a-z]+
    

    You need to read on the 'border' meta-characters. Try [url http://download.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html#sum] here to start; Although you'd probably better go through [url http://download.oracle.com/javase/tutorial/essential/regex/] tutorial.

    Winston

  • Are there reasons why T/B could not support wildcard (* xyzpqr *) or regular expressions in search of content of e-mail?

    When a string of characters, I'm interested, is buried in an e-mail, I would find these emails. It seems that as the code needed to find an email is already in place, it would take very little effort/code/support added to extend the search capabilities of more effectively, as it is available in spreadsheets.

    This particular forum has these capabilities, suggesting that users find useful installation.

    Are there reasons preventing these facilities being added to T/B? I find that the ability would frequently help me in search of my email.

    FiltaQuilla both Expression search/GmailUI provide functionality, specifically the regular expressions.

    FiltaQuilla aims to improve the message filters and has a useful side effect in improving the CTRL + SHIFT + f find. Research of expression increases the QuickFilter bar. Or rather weird global research assistance, but I work around this by using a Saved Search folder, where you use a dialog similar to the message filters and can make use of the enhancements offered by one of these modules.

  • The z570 has not a regular Express card slot (only a mini one)?

    The z570 has not a regular Express card slot (only a mini one)?

    Hi KiteEye and welcome to the community,

    It doesn't have an Express card slot.

    The small slot located is a memory card reader.

    Dave

  • regular expression

    According to the link below, TS supports regular expressions.  Can anyone provide an example where to write regular expressions?

    I might be easier to do via a plug-in of .net, but TS permitting, I might go with it.

    http://zone.NI.com/reference/en-XX/help/370052N-01/tsref/infotopics/find_regular_expressions/

    Hello

    Yes, there is a member of the PropertyObject.Search, but the result is search results, so I wonder how to use in the execution sequence?

    What a simple solution using only 4 lines in Exression statement to realize this split and trim?

    Concerning

    Jürgen

  • Problem on regular expressions

    Hi all

    I'm working on a project that require me to separate the following examples:

    + 0, + 0.0000 E1, - 4.33 + E1, - 4.222 + E1, - 6.33 + E2, - 6.55 + E2

    What I need is the final four results separately:

    -4.33 + E1.

    -4.222 + E1,

    -6.33_E2,

    -6.55 + E2.

    I'm totally cool regular expression. Any help is appreciated!

    Thank you

    + Kunsheng

    Hi, Kunsheng

    Good evening exercise to learn regular expressions...

    For example, quick and dirty:

    I have the strong feeling that something's wrong here (I guess in ([0-9] + [1-9] +)), but in any case the above code is just starting point for you.

    Andrey.

  • Use matching of regular expressions to search for parentheses

    Hi all

    I am currently looking for a particular pattern in a string, I can't display the exact string, but say its something like that.        corresponds to regular_pattern (5000): 0

    I'm also looking for the a different model at the same time, so I have to use the corresponding regular expression and the | function.  I can't understand how to match this model because the regular expression function allows parentheses unless I put them in the legs, and that does not help me for this.

    Any advice?

    Thank you

    Matt

    Have you tried to escape the bracket?

  • Regular expression matching receives only two digit in brackets

    Hello

    I use the regular expression of the correspondence with the following expression. It is only able to get all the numbers that are not mere numbers. I want to retrieve all the values which lie between >< in="" the="" string="" and="" create="" an="">

    Then

    182
    2

    would be output

    182

    2

    Any help would be appreciated. I've attached what I have so far. Right now I still have the >< and="" it="" can="" only="" grab="" numbers="" that="" are="" not="" single="">

    Use (>.) [ ^(<>)]*)<    *="" instead="" of="">

Maybe you are looking for