Format String with pattern

Hi Folks,
my Problem is that i need to format a String by using a pattern.
The Input String is like "20081208" and the Output String has to be "2008-12-08".
I could simply do this by using String.substring but i think it's not that elegant.
Also i found a way by doing it with SimpleDateFormat.
But it needs to much lines of code to do this as it's worth.
Is there a simple way like String.format just to do this in one line?
I'd like to pass the String which should be formatted and a format String to a method and it gives me the result.
Thanks in advance,
xtremliep

Darryl.Burke wrote:
System.out.println("20081208".replaceAll("(\\d{4})(\\d{2})(\\d{2})", "$1-$2-$3"));Note that if you're processing a large amount of data, this will almost certainly be slower than using a StringBuffer as already advised by two members.You can get a big performance boost by pre-compiling the regex and instantiating the Matcher ahead of time:
static final Matcher matcher = Pattern.compile("(\\d{4})(\\d{2})(\\d{2})").matcher("");
String newString = matcher.reset(oldString).replaceFirst("$1-$2-$3"); It will probably still be slower than the StringBuilder solution, but not by much. Of course, if the data is really huge, even a very small difference can have a noticeable impact.

Similar Messages

  • Problem formatting string with ints

    I'm trying to perform simple string formatting using a resource file but I'm having problems when I pass integers to the format argument.
    Here is the line of code that causes the IllegalFormatConversionException:
    ResourceFile.getFormattedString("XMLGAME",myBounds.getWidth(),myBounds.getHeight())//myBounds.getWidth() and myBounds.getHeight() return intsHere is the method in ResourceFile:
    public static String getFormattedString(String resource, int... args)
        return String.format(resourceFile.getString(resource), args);
    }And here is the string in the properties file
    XMLGAME  <game name="game" width="%d" height="%d">\nEdited by: JFactor2004 on Dec 3, 2008 10:15 PM

    Instead of {color:000080}int{color}..., declare "args" the same way format() does, as Object...: public static String getFormattedString(String resource, Object... args) The way you're doing it would require the {color:000080}int{color}[] to be "bulk-autoboxed" to an Integer[] or Object[], and Java can't do that. Instead, it treats "args" as an Object[] containing one element, which happens to be an {color:000080}int{color}[].

  • SQL Error: ORA-01861: literal does not match format string

    Hello,
    I'm trying to do data mining on a web log which recorded one day web access information from a busy web server. I imported the data into Oracle Data miner, and created a table (WEBLOG). The idea is to create a new field, i.e. session, for the users so that each session could be thought as a representative of a user-intent (aka topic). Now based on this, data mining models would be used to cluster(group) the users based on their similarity. The first step is to prepare the data which involves using SQL queries. So first, all I did was to create a function for date and time. This is the following code I used,
    create or replace function ssndate(p_date in varchar2 default '03-01-18',
    p_time in varchar2)
    return number
    $if dbms_db_version.ver_le_10 $then
    deterministic
    $elsif dbms_db_version.ver_le_11 $then
    result_cache
    $end
    as
    begin
    return trunc((to_date(p_date||' '||p_time, 'dd-mm-yy hh24:mi:ss')
    - to_date('01-01-90','dd-mm-yy')) * (86400/2400));
    end ssndate;
    The function ssndate compiled successfully.
    The next step I took was to create a view through the following query,
    create or replace view WEBLOG_VIEWS
    as
    select (select ssndate(LOG_DATE, LOG_TIME) from dual) as "SESSION_DT",
    C_IP,
    CS_USER_AGENT,
    (CS_URI_STEM||'?'||CS_URI_QUERY) as WEB_LINK
    from WEBLOG;
    This was successful as well. The problem is in the next step where I try to do data grouping.
    create table FINAL_WEBLOG as
    select SESSION_DT, C_IP, CS_USER_AGENT,
    listagg(WEB_LINK, ' ')
    within group(order by C_IP, CS_USER_AGENT) "WEB_LINKS"
    from WEBLOG_VIEWS
    group by C_IP, CS_USER_AGENT, SESSION_DT
    order by SESSION_DT
    For this, I got the error,
    Error starting at line 1 in command:
    create table FINAL_LOG as
    select SESSION_DT, C_IP, CS_USER_AGENT,
    listagg(WEB_LINK, ' ')
    within group(order by C_IP, CS_USER_AGENT) "WEB_LINKS"
    from WEBLOG_VIEWS
    group by C_IP, CS_USER_AGENT, SESSION_DT
    order by SESSION_DT
    Error at Command Line:1 Column:7
    Error report:
    SQL Error: ORA-01861: literal does not match format string
    ORA-06512: at "DMUSER.SSNDATE", line 11
    ORA-06512: at line 1
    01861. 00000 - "literal does not match format string"
    *Cause:    Literals in the input must be the same length as literals in
    the format string (with the exception of leading whitespace).
    If the "FX" modifier has been toggled on, the literal must
    match exactly, with no extra whitespace.
    *Action:   Correct the format string to match the literal.
    I don't know where I'm going wrong with this.. the to_date function should be fine. In the data that I possess, the date and time are in no format. Example: 30118 and 0:00:09 respectively. If anyone has any clue about this I would be sincerely grateful for any help that I can get!! It's quite urgent..
    The Oracle version is 11.2.0.1.0
    Edited by: 975265 on Dec 5, 2012 5:31 PM

    975265 wrote:
    Ok.. Looks like I touched a nerve there. I apologize. I'm still a student, and this is the first time that I've tried something at this level. I'm still in the learning process, so I was hoping that someone could point me in the right direction in order to "fix" the data.Not so much touching a nerve as simply trying to implement a very very poor, but all too common, practice. Since you are a student (which we didn't know until this post) most people will cut you some slack. However, this little exchange should now be burned into your brain as you move forward. One of the very first rules of programming is to ALWAYS use the correct data types for your data. And along with that, never ever depend on implicit type conversions - always use the proper explicit conversion functions.
    And as a slight follow-on, when considering the appropriate data type, don't assume that just because we refer to a given element as a 'something number' that it is indeed a number. Telephone "numbers" are NOT numbers. U.S. Social Security "numbers" are NOT numbers. U.S. Postal Zip codes are NOT numbers. All are just character strings which, by convention, we limit to the same characters we use to represent numbers.
    And since this entire discussion came up around the representation of dates, you might want to take a look at http://edstevensdba.wordpress.com/2011/04/07/nls_date_format/
    Now, go forth and be a smarter programmer than your peers.
    Edited by: EdStevens on Dec 6, 2012 6:12 AM

  • Load associate format string using DLR

    Hi,
    I'm trying to load an associate format string with a DLR from a text datafile.
    My DLR has been built like this :
    PARENT0,Account CHILD0, Account ALIAS0,Account PROPERTY0,Account PROPERTY0,Account PROPERTY0,Account
    Father Child Alias Store ^ mdxformat(...)
    The mdxformat(...) code works fine when I add it manually in the outline via EAS
    But everytime I load with a DLR I got this error message
    \\Record #23 - Error adding Dynamic calc property to member Child (3320)
    \\Record #23 -      Level 0 virtual members must have a formula associated with them
    I'm using Essbase 11.1.2
    I removed the mdxformat from my datafile and the member is load properly.
    Regards,
    Franck

    Finally no solution, I added it manually

  • Currency formating with pattern specified

    Hi,
    I am trying to format value with Currency,in which I am successful.
    Now I want to apply some specific pattern over a number and then
    it should give me Currency formated value.
    For e.g.
    My value is "5000.25"
    I apply patter formating over it like #,##,#.00
    I convert it into currency so I should see in (US Locale)
    $5,00,0.25
    In below code I can achive either of them If I comment
    "applyLocalizedPattern" method.
    import java.text.DecimalFormat;
    import java.util.Locale;
    import java.text.*;
    import java.util.*;
    import sun.text.resources.LocaleData;
    public class CurrencyFormat
         public static void main(String args[])
              NumberFormat useFormat = NumberFormat.getCurrencyInstance(Locale.US);
              DecimalFormat dc = (DecimalFormat) useFormat;
              DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.US);
              double amount = 5000.25;
              symbols.setCurrencySymbol("*");
              dc.applyLocalizedPattern("#,#,#,#.00");
              dc.setDecimalFormatSymbols(symbols);
              System.out.println(useFormat.format(amount));
    }

    if you define a custom format that doesn't include any currency sign like "#,#,#,#.00", the currency sign is not added... to make it use the currency sign as per the docs "\u00a4 #,#,#,#.00"dc.applyLocalizedPattern("\u00a4#,#,#,#.00");

  • Validate String with a pattern

    How can we validate the string with a pattern?
    eg. Value should always be of the format C-DDD,
    where C is a character (A-Z or a-z) and
              D represents a digit(0-9)
    Valid forms are A-001, A-987, Z-098 and
    not valid forms are A-01, 1-A01, 1- 0A0, A-A01, A-0001
    Say internal table contains values like this.
    F1     F2      F3
    1     00001  A-001
    2     00001  A-A01
    3     00001  B-909
    4     00001  Z-01
    5     00001  k-0001
    Valid records are 1 and 3.

    Hi,
    you can use regular expressions for this, e.g.:
      FIND ALL OCCURRENCES OF REGEX '[a-z,A-Z]-[0-9]{3}[ [:blank:] ]'
           IN TABLE t_data
           RESPECTING CASE
           RESULTS t_results.
    Note that in the above example all fields in the table will be checked. If this is not practical for your use you can use a LOOP and FIND on the table field.
    Note that line 5 in your example also matches the pattern you have given. If you really do not want to see this as valid you will have to use the pattern: '[A-Z]-[0-9][ [:blank:] ]'. The addition of [ [:blank:] ] is only needed if your field is longer than the pattern, i.e. 5 characters.
    Good luck,
    Gert.
    Edit: This will also be pretty efficient.
    Edited by: Gert Beukema on Jul 15, 2008 10:36 AM

  • Formatting a string with time stamp and double precision numbers

    %s\t%f\r%f
    This is a format string that I have in old code that I've decided to change.  Problem is I cannot make sense of the string codes in my own old code! Let me explain what I want, and hopefully someone can explain how to do it.
    I am using the format into string subvi to merge a time stamp (formatted as %m%d%Y%H%M%S%5u) and two different double precision numbers.  This string is then wired into the Write Characters to File subvi so that I can record data as a .txt file, and open it in either Matlab or Excel.  There is a minor problem with the string format above because in excel the first time stamp entry is blank, and the first loop only gives the two double precision numbers withouth the time stamp - the time stamp appears in the next loop (probably a looping issue and not due to the string format, but if you see differently please let me know).  Now what I want to do is 1. potentially fix that problem and 2. add some more doubles. 
    1. Is there a string format issue that is evident that I am not seeing that causes the time stamp to be formatted into the string after a carriage return?  Or should I be looking at looping issues?
    2. How do I add another one - three floating point numbers (double precision)?  Are the \'s marking different numbers in this string constant?  Or is it the %?  I can't find any information about the \'s, but I see that % begins the format specifier. 
    Ideally, I want these data in the following columns:  Date, Time(absolute), FP, FP, FP, carriage return for the next loop (FP is floating point double precision number).
    Thanks,
    Brad

    Hi JonN,
    Here there is no need of string concordinate function (in your code), the same result you can find if you connect the output of the format string to shift register, and shift register in data to initialize string connector in format into string function.
    <<KUDOS ARE WELCOME>>
    ELECTRO SAM
    For God so loved the world that he gave his one and only Son, that whoever believes in him shall not perish but have eternal life.
    - John 3:16

  • Formatting a string with Display String

    I have a field in my database that is a string with numbers in it and I need it formatted like so: "xx-xx-xx-xxx" nine characters long.
    For example: 92438014
    I need it to look like: 09-24-38-014
    and
    141234892
    14-12-34-892 etc..
    can anyone help me with some code that will do this for me? I'm not the best at crystal custom formatting.
    thank you
    Edited by: MarcieHennessy on Oct 14, 2009 10:47 PM

    Raghavendra.G
    I was on this site searching for an answer to my problem, and you provided the solution for me with your response to the above.  However, my problem was a bit different.  I needed a way to format a 9-digit number string into a standard Social Security number format.  I used your formula from above, and WOW - it worked!  If I could award you double Forum Points, I would.  But, since I can't do that, I will just say thanks, and ask God to bless you profusely.
    Kathryn J. Ryan.

  • Formatting a timestamp into string with $ specifier

    Formatting a timestamp into string with $ specifier does not work; the formatted string is empty and no error is reported:
    I have forced the width to 10 to show that the format is at least partially scanned but when it is omitted the timestamp field is empty.
    I couldn't find this problem reported/addressed so here it is (LabVIEW 8.6)
    LabVIEW, C'est LabVIEW

    Yes, the simple work around is to put the timestamp first in both the string and the inputs.  But this is a bug.  There is no doubt about that.  A high priority?  Probably not.  Something that should be looked for when doing a revamp of the Format String?  Yep.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Premiere sends EDL with 'invalid timecode format string'

    Following the suggestions in this thread, I am attempting to send an EDL of a Premiere sequence to Speedgrade.
    When I attempt to import the EDL into Speedgrade I get this error message:
    ERROR
    In point timecode is invalid. Invalid timecode format string(hours): '23813+20'
    in edit 1
    File: 001 LR001 V C 2813+20 23815+17 0:00 1+37
    Line: 2
    I've worked very rarely with EDLs but have read the Speedgrade and Premiere guides. I must be missing something but can't tell what.  Here's the details from my project:
    I'm editing in 24fps. The video files are generated in After Effects from DPX files. The timecode is based on the DPX file names, with the hour matching the Lab Roll number (so 11:00:00 for Roll 11)
    I export an EDL in CMX3600 format. I've tried both default settings and without audio. Same results. I even get the same result if I make a sequence from a single clip and try exporting that EDL.
    I don't think this is a Speedgrade issue, because if I try re-importing the EDL into Premiere, it seems like all the clips are only one frame long.
    Any suggestions about what I might be doing incorrectly would be greatly appreciated.
    Thanks,
    Lev         

    Are you wanting to just simply go from Premiere to Speedgrade? If so why not just use the "send to speedgrade" choice. Also I wanted to point out in the original thread you actually said you didn't want to use speedgrade, I've never used a EDL with speedgrade so I have 0 ideas there, but have you tried just using Premiere's built in send to speedgrade function?

  • Check string validity with pattern

    hello,
    I want to check the validity of strings given by the user. The only characters authorized are : 'a' to 'z', 'A' to 'Z', '0' to '9', '.', '-', '_', '*', '@' and ' ' (space)
    i want to check this string with a pattern but it does not work.
    Somebody can help me for the pattern because the API javadoc is poor and i have a limited web access in my agency.
    Thanks
       String regex = "[a-zA-Z0-9.*-_@]";
       System.out.println(regex);
       boolean bol = Pattern.matches(regex, field);
       System.out.println(bol);
       ->> result always false for string field="Indy jones";

    try this:
    import java.sql.*;
    import java.io.*;
    import java.util.regex.*;
    import java.util.*;
    public class RegExTest2 {
    public static void main (String args[]) {
    Pattern pat = null;
    Matcher m = null;
    String patternToMatch = "^[a-zA-Z0-9\\.\\*\\-\\_@\\s]+$";
    String line1 = "IndianaJones";
    String line2 = "Indiana Jones";
    String line3 = "Indiana - Jones";
    String line4 = "Indiana&Jones";
    String line5 = "Indiana & Jones";
    String line6 = "  Indiana Jones  ";
    String line7 = "Indiana Jones =";
    pat = Pattern.compile(patternToMatch);
    System.out.println("Pattern to match = " + patternToMatch);
    boolean bol = Pattern.matches(patternToMatch, line1);  
    System.out.println("line1 : expected true and got " + bol);
    bol = Pattern.matches(patternToMatch, line2);  
    System.out.println("line2 : expected true and got " + bol);
    bol = Pattern.matches(patternToMatch, line3);  
    System.out.println("line3 : expected true and got " + bol);
    bol = Pattern.matches(patternToMatch, line4);  
    System.out.println("line4 : expected false and got " + bol);
    bol = Pattern.matches(patternToMatch, line5);  
    System.out.println("line5 : expected false and got " + bol);
    bol = Pattern.matches(patternToMatch, line6);  
    System.out.println("line6 : expected true and got " + bol);
    bol = Pattern.matches(patternToMatch, line7);  
    System.out.println("line7 : expected false and got " + bol);
      } // end main
    } //End Class RegExTest2

  • What is a formatted string?

    does anyone know what a "formatted string" is?
    Thanks.

    That could perhaps refer to the Format classes in java.text. For example if you have a Date object that you want to format in a certain with given a pattern, you can use the SimpleDateFormat. Those classes can also be used to parse strings. DecimalFormat is used to format numbers, and MessageFormat can format a string providing up to 10 values that can be a mix of e.g. Number, Date and String objects.
    More general a formatted string is just a string that has been formatted in a specific way given some values.

  • Creating a string with hiearchical data

    This is being done in Crystal 8 will all updates applied.
    I have a database with records that are linked to a series of "folders" that are hierarchical in nature as shown below:
    Folder 1:
         Folder 1.1
              Folder 1.1.1
    Folder 2
        Folder 2.1
    All of the folders can have data records attached to them.
    The database represents the folder structure in a table with the following attributes:
    Folder ID   (integer)
    Folder Name (String)  (such as "Folder 1"
    Folder Parent ID (integer)
    (other non-related fields)
    If the folder is at the root level, then the value in Folder Parent ID is 0, otherwise, it is the Folder ID of the parent folder.
    I need to be able to create a string field that displays the path for any given folder that I can insert into a group header or footer, or into a report header if the report deals with records in a single folder.  Desired format for the  string is: 
    "Folder 1> Folder 1.1> Folder 1.1.1"
    I need to be able to display at least 6 levels of folder indentation.
    I have tried several ways to create a formula that will reliably produce the desired string, and can get close, but cannot completely address the problem.  My most successful approach was to put multiple instance of the table into the report and link the Folder Parent ID of one level to the Folder ID of the next level down and then use the data to build the string with a formula like this:
    Local StringVar Result := {portfolio_master.portfolio_name};
    local stringvar ExitLoop := "1" ;
    if  ExitLoop = "1" then
        Result := {portfolio_master_1.portfolio_name} + "> " + Result
    else
        ExitLoop := "0";
    if {portfolio_master_1.parent_id} NE 0 AND ExitLoop = "1" then  // NE replaces Crystal not equal symbol which will not show
        Result := {portfolio_master_2.portfolio_name} + "> " + Result
    else
        ExitLoop := "0";
    if {portfolio_master_2.parent_id} NE 0 and ExitLoop = "1" then
        Result := {portfolio_master_3.portfolio_name} + "> " + Result
    else
        ExitLoop := "0";
    if {portfolio_master_3.parent_id} NE 0 and ExitLoop = "1" then
        Result := {portfolio_master_4.portfolio_name} + "> " + Result
    else
        ExitLoop := "0";
    if {portfolio_master_4.parent_id} NE 0 and ExitLoop = "1" then
        Result := {portfolio_master_5.portfolio_name} + "> " + Result
    else
        ExitLoop := "0";
    Result;
    This formula works so long as the folder in question is exactly 5 levels deep.  Changing the nature of the links(inner join, left outer join etc.) between the instances of the table in the Database Expert changes the data that is visible, but I can't find a combination that will show ALL of the needed information for all of the folders. 
    I understand that this is a brute force approach, and that there must be a different way to skin the cat.  My preference would be to "walk the tree" with a loop structure, but I don't see any way to do the needed data look up within the loop.
    Any suggestions would be greatly appreciated!
    Thanks,
    L. Jasmann
    Edited by: ljasmann1 on Jun 23, 2010 9:09 PM
    Edited by: ljasmann1 on Jun 23, 2010 9:33 PM

    I have been working to adapt the code provided above to my application.  Although I have worked with Crystal for quite a while, this is the first time that I have attempted to use SQL in Crystal... and it is just not working.. probably because I am no doing something very basic.
    Here is  the code as currently set up in the SQL Formula Editor.  Only major difference from the code provided above is that the ID fields are integers instead of strings, and the field that I want to print out is a string field separate from the ID fields....  I have substituted the field names from the table I am referencing for the ones in the code above.  The table that I am using has been selected using the Database Expert.
    DECLARE @Value int, @pf int, @FolderPath VarChar(MAX)
    SET @Value = "portfolio_master"."portfolio_id"
    SELECT @pf = "portfolio_master"."parent_id" FROM portfolio_master WHERE "portfolio_master"."portfolio_id" = @Value
    SET @FolderPath = "portfolio_master"."portfolio_name"
    WHILE @pf <> 0
    BEGIN
    SET @Value = @pf
    SELECT @pf = "portfolio_master"."parent_id" FROM portfolio_master WHERE "portfolio_master"."portfolio_id" = @Value
    SET @FolderPath = "portfolio_master"."portfolio_name" + ' > ' + @FolderPath
    END
    SELECT @FolderPath AS FolderPath
    When I test the SQL statement it errors out on the very first statement (the DECLARE statement).  If I substitute a different statement in front of the DECLARE statement, it errors on that statement.
    Here is the error that I get back. The database is using MS SQL Server.
    Error in compiling SQL Expression:
    Failed to retrieve data from the database.
    Details:  ADO Error Code:  0x80040e14
    Source:  Microsoft OLE db Provider for SQL Server
    Description:  Incorrect syntax near the keyword u2018DECLAREu2019,
    SQL State:  42000
    Native Error:  156 [Database Vendor Code:  156].
    Any pointers would be greatly appreciated...
    Thanks,
    Larry Jasmann

  • How Can I replace newScale Text Strings with Custom Values?

    How Can I replace newScale Text Strings with Custom Values?
    How can I replace newScale text strings with custom values?
    All  newScale text is customizable. Follow the procedure below to change the  value of any text string that appears in RequestCenter online pages.
    Procedure
    1. Find out the String ID of the text string you would like to overwrite by turning on the String ID display:
    a) Navigate to the RequestCenter.ear/config directory.
    b) Open the newscale.properties file and add the following name-value pair at the end of the file:res.format=2
    c) Save the file.
    d) Repeat steps b and c for the RmiConfig.prop and RequestCenter.prop files.
    e) Stop and restart the RequestCenter service.
    f) Log  in to RequestCenter and browse to the page that has the text you want  to overwrite. In front of the text you will now see the String ID.
    g) Note down the String ID's you want to change.
    2. Navigate to the directory: /RequestCenter.ear/RequestCenter.war/WEB-INF/classes/com/newscale/bfw.
    3. Create the following sub-directory: res/resources
    4. Create the following empty text files in the directory you just created:
    RequestCenter_0.properties
    RequestCenter_1.properties
    RequestCenter_2.properties
    RequestCenter_3.properties
    RequestCenter_4.properties
    RequestCenter_5.properties
    RequestCenter_6.properties
    RequestCenter_7.properties
    5. Add the custom text strings to the appropriate  RequestCenter_<Number>.properties file in the following manner  (name-value pair) StringID=YourCustomTextString
    Example: The StringID for "Available Work" in ServiceManager is 699.
    If you wanted to change "Available Work" to "General Inbox", you  would add the following line to the RequestCenter_0.properties file
         699=General Inbox
    Strings are divided into the following files, based on their numeric ID:
    Strings are divided into the following files, based on their numeric ID:
    String ID  File Name
    0 to 999 -> RequestCenter_0.properties
    1000 to 1999 -> RequestCenter_1.properties
    2000 to 2999 -> RequestCenter_2.properties
    3000 to 3999 -> RequestCenter_3.properties
    4000 to 4999 -> RequestCenter_4.properties
    5000 to 5999 -> RequestCenter_5.properties
    6000 to 6999 -> RequestCenter_6.properties
    7000 to 7999 -> RequestCenter_7.properties
    6. Turn off the String ID display by removing (or commenting out) the line "res.format=2" from the newscale.properties, RequestCenter.prop and RmiConfig.prop files
    7. Restart RequestCenter.
    Your customized text should be displayed.

    I've recently come across this information and it was very helpful in changing some of the inline text.
    However, one place that seemed out of reach with this method was the three main buttons on an "Order" page.  Specifically the "Add & Review Order" button was confusing some of our users.
    Through the use of JavaScript we were able to modify the label of this button.  We placed JS in the footer.html file that changes the value of the butt

  • Parsing formatted String to Int

    How can I parse formatted string to Integer ?
    I have a formated string like this $900,000 and I need to convert it to 900000 so I could do calculations with it.
    I tried something like this
    NumberFormat nf = NumberFormat.getIntegerInstance(request.getLocale());
    ttlMargin=nf.parse(screenVal);I got this exception
    "java.lang.NumberFormatException: For input string: "$1,050,000""

    I am working on the JSP file that provides
    margins,sales etc. I am reading this data off the
    screen where it is beeing displayed according to the
    accounting practices.
    That's why I get it as a formatted string and why I
    am trying covert that string to the numberScreen-scraping is a problematic, bad design. It sounds like what you really want is to call a web service which returns its results as data that a program can understand (XML, for example), not HTML (which is meant more for humans to read). I know, you probably can't change the design at this point... just food for thought. In the meantime, you'll probably have to manually parse those strings yourself by stripping out the '$' and ',' characters and then use parseInt on the result.

Maybe you are looking for