Match string and retrieve part of string from match

Hi,
I'm trying to parse a html-page to retrieve a certain value.
The string should match some pattern. Then I want to retrieve a part of the string from the match. In my example case: XXX.
String string2Match = "    <input type=\"text\" name=\"match\" value=\"XXX\"       ";
String regex = ".*<input type=\"text\" name=\"match\" value=\"\\w*\".*";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(string2Match);
if (matcher.matches()) {
   // in this case I want to retrieve a part of the string from the match. here: XXX.
}Can this be done, without parsing the matcher.group()-findings again.
Thanks
Jonny

user11365587 wrote:
My question was meant for strings in general.Then go here:
http://download.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html
and look for groups.
You will end up by something like:Matcher matcher = Pattern.compile("[a-z]{2}(\\d+)(.*)").matcher("ab1234xy56");
assertEquals("ab1234xy56",matcher.group(0));
assertEquals("1234",matcher.group(1));
assertEquals("xy56",matcher.group(2));bye
TPD

Similar Messages

  • How can I login and retrieve my user file from the trash?

    I was trying to find out where all my HD had gone, which a did using ‘What Size’.
    I found what looked like an old backup file so I put the file in the trash.
    It turns out that the file was my user file. So now I can’t login to as the user.
    How can I login and retrieve my user file from the trash?

    The Digital Editions forum is here, in case this is what you are talking about:
    http://forums.adobe.com/community/adobe_digital_editions
    If you are not, I apologize for the misunderstanding.

  • Finding and retrieving an XML file from an application and an applet

    I have a problem.
    I have data stored in an XML file. I want to be able to call that file and store it into a document object from an application standing alone on a computer as weel as from an applet that would be running over the web.
    I don't know how to do this.
    When I use a relative path name for the application it attaches the path of the folder that contains java.exe. I could do something with the class path but this wouldn't help the end user of the application on a different computer. For similar reasons I don't want to hard code because I don't know where the final applet will be stored.
    I have a table that holds, sorts and filters the data so I want the table to collect the data, I don't want to dictate the path from the applet or the application, I want a method that is consistant with both scenarios.
    Can anyone offer some advice?

    I've just finished trying it out, here is what I did:
    String xmlDocName="filename.xml";
    java.net.URL fileURL=this.getClass().getResource(xmlDocName);
    private final String fileName = fileURL.toString().substring(6);
    The substring removes the "file:/" from the URL.
    This works fine in the IDE, I have even stored the xml file in a lower folder e.g. package_folder/xml_folder/filename.xml and replaced the xmlDocName with "xml_folder/filename.xml" and it worked fine.
    I haven't tried it in an applet because I'm running IE and as you are well aware there are problems with swing and IE applets. But you answer deserves the Duke Dollars, thank you very much.

  • Cut and Paste part of image from Photoshop to .csv template

    Hi all,
    I have my own javascript to determine which portion(coordinates) of an image i wish to cut.
    But what codes can i add to my javascript to paste the image into an excel(.csv) template that i've prepared on the desktop?
    And if the above is possible, how then to control which row/column in the excel(.csv) will the image be pasted in?
    This is because the excel(.csv) is a Template, thus i will need the image to be pasted only in certain row/column...
    Can someone help me?
    Thanks so much in advance.

    Very strange, I created the relevant folders and it all seems to work ok here, so don't know what's gone wrong?
    #target photoshop
    function main(){
    if(!documents.length) return;
    var paper_no=900;
    var Excel = File("~/desktop/myfolder/records/"+Number(paper_no)+".xls");
    var Cell ="C22";
    if(!Excel.exists){
        alert("SpreadSheet does not exist!");
        return;
    try{
    var SB = app.activeDocument.selection.bounds;
    }catch(e){return;}
    app.activeDocument.selection.copy();
    var Width = SB[2].as('px') - SB[0].as('px');
    var Height = SB[3].as('px') - SB[1].as('px');
    var doc = app.documents.add(UnitValue(Width,'px'),UnitValue(Height,'px'),72);
    app.activeDocument.paste();
    doc.flatten();
    var tmpFile = File(Folder.temp +"/deleteMe.jpg");
    if(tmpFile.exists) tmpFile.remove();
    SaveForWeb(tmpFile,60);
    app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
    var VBS = File(Folder.temp +"/VBS.vbs");
    VBS.open('w');
    VBS.writeln('Set objExcel = CreateObject("Excel.Application")');
    VBS.writeln('Set objWorkbook = objExcel.Workbooks.Open("'+decodeURI(Excel.fsName)+'")');
    VBS.writeln('objExcel.Visible = false');
    VBS.writeln('Set mypic = objWorkbook.ActiveSheet.Pictures.Insert("'+decodeURI(tmpFile.fsName)+'")');
    VBS.writeln('mypic.Top = objWorkbook.ActiveSheet.Range("'+Cell+'").Top');
    VBS.writeln('mypic.Left = objWorkbook.ActiveSheet.Range("'+Cell+'").Left');
    VBS.writeln('mypic.Width = objWorkbook.ActiveSheet.Range("'+Cell+'").Width');
    VBS.writeln('mypic.Height = objWorkbook.ActiveSheet.Range("'+Cell+'").Height');
    VBS.writeln('objExcel.ActiveWorkBook.Close True');
    VBS.close();
    VBS.execute();
    main();
    function SaveForWeb(saveFile,jpegQuality) {
    var sfwOptions = new ExportOptionsSaveForWeb();
       sfwOptions.format = SaveDocumentType.JPEG;
       sfwOptions.includeProfile = false;
       sfwOptions.interlaced = 0;
       sfwOptions.optimized = true;
       sfwOptions.quality = jpegQuality;
    activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions);

  • How to store and retrieve chinese characters

    Hi, I am facing some problem in storing and retrieving of chinese characters from oracle,9i .
    This is the character i am trying to store into the database
    自动提款机网络
    while trying to retrieve it, it shows
    自?提款机网?
    ^ ^
    you can see the weird characters like ? at some places.
    here is the sample code which i can using to store and retrieve data from the database
    class testInsert
    public static void main(String[] args)
    try {
         DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
         Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@172.16.6.81:1521:JFPPTDB1", "citi_user", "citi_user");
         int employee_id = 12345;
    String ename = "自动提款机网络";
         oracle.jdbc.OraclePreparedStatement pstmt = (oracle.jdbc.OraclePreparedStatement)conn.prepareStatement("INSERT INTO employees (employee_id, last_name) VALUES (?, ?)");
         pstmt.setFormOfUse(2, oracle.jdbc.OraclePreparedStatement.FORM_NCHAR);
         pstmt.setInt(1, employee_id);
         pstmt.setString(2, ename);
         pstmt.execute();
    pstmt.close();
    pstmt = (oracle.jdbc.OraclePreparedStatement)conn.prepareStatement("SELECT last_name, employee_id from employees");
    ResultSet rset = pstmt.executeQuery();
              String name = "";
              while(rset.next())
                   name = rset.getString(1);
         int id = rset.getInt(2);
              System.out.println("the name is :"+name);
    catch (SQLException sqe)
              System.out.println("Java SQLException caught, error message="+sqe.getMessage());
    and the table in oracle is
    SQL> desc employees;
    Name Null? Type
    LAST_NAME NVARCHAR2(10)
    EMPLOYEE_ID NUMBER
    I am using classes12.zip for oracle,9i. Is there any database setting that i need to know to retrieve the chinese characters?.
    I have been facing this problem for quite sometime and it makes my life tough. Please help me in solving this issue.
    Thanks
    PD

    hi, can you retrieve the chinese character from your os? When it comes to the wild code of asian character, you should focus on the database/client character setting. you may ask more about it from your dba.
    have a nice weekend!
    eilison
    [email protected]

  • I deleted an e-mail from my iCloud account from my iPhone and cleared the trash. I accidentally deleted an e-mail from my college containing a string of 3 e-mails which are very important. Is there anyway to retrieve the e-mail from the Apple server?

    I deleted an e-mail from my iCloud account from my iPhone and cleared the trash. I accidentally deleted an e-mail from my college containing a string of 3 e-mails which are very important. Is there anyway to retrieve the e-mail from the Apple server?

    My question is similar:  I deleted email folders in my mail app on iPhone 4 and it deleted the folders on all my other devices--literally THOUSANDS of emails!  I went to iCloud to recover them and can't find them.  HELP PLEASE!

  • XML Report completes with error due to REP-271504897:  Unable to retrieve a string from the Report Builder message file.

    We are in the middle of testing our R12 Upgrade.  I am getting this error from the invoice XML-based report that we are using in R12. (based on log).  Only for a specific invoice number that this error is appearing.  The trace is not showing me anything.  I don't know how to proceed on how to debug where the error is coming from and how to fix this.  I found a patch 8339196 that shows exactly the same error number but however, I have to reproduce the error in another test instance before we apply the patch.  I created exactly the same order and interface to AR and it doesnt generate an error.  I even copied the order and interface to AR and it doesn't complete with error.  It is only for this particular invoice that is having an issue and I need to get the root cause as to why.  Please help.  I appreciate what you all can contribute to identify and fix our issue.  We have not faced this issue in R11i that we are maintaining right now for the same program which has been running for sometime.  However, after the upgrade for this particular data that the user has created, it is throwing this error REP-271504897.
    MSG-00100: DEBUG:  Get_Country_Description Return value:
    MSG-00100: DEBUG:  Get_Country_Description Return value:
    REP-0002: Unable to retrieve a string from the Report Builder message file.
    REP-271504897:
    REP-0069: Internal error
    REP-57054: In-process job terminated:Terminated with error:
    REP-271504897: MSG-00100: DEBUG:  BeforeReport_Trigger +
    MSG-00100: DEBUG:  AfterParam_Procs.Populate_Printing_Option
    MSG-00100: DEBUG:  AfterParam_Procs.Populate_Tax_Printing_Option
    MSG-00100: DEBUG:  BeforeReport_Trigger.Get_Message_Details
    MSG-00100: DEBUG:  BeforeReport_Trigger.Get_Org_Profile.
    MSG-00100: DEBUG:  Organization Id:  117
    MSG-00100: DEBUG:  BeforeReport_Trigger.Build_Where_Clause
    MSG-00100: DEBUG:  P_Choi
    Report Builder: Release 10.1.2.3.0 - Production on Tue Jul 23 09:56:46 2013
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.

    Hi,
    Check on this note also : Purchasing Reports Fail When Changing Output To XML REP-0002 REP-271504897 REP-57054 (Doc ID 1452608.1)
    If you cant reproduce the issue on other instance, apply the patch on the test instance and verify all the funcionality related to the patch works OK. Then move the patch to production. Or you can clone the prod environment to test the patch.
    Regards,

  • REP-0002: Unable to retrieve a string from the Report Builder message file;

    Hi,
    I've a custom report in which i need to display a large string, of more than 4000 characters. To cater to this requirement i've written a formula column which displays string upto 4k characters and for a string of size beyond 4k i am calling a procedure which uses a temp table having a clob field.
    For a small string the report runs fine but whenever a large string requirement comes into the picture, said procedure gets triggered and i get REP-0002: Unable to retrieve a string from the Report Builder message file.
    OPP log for the same gives an output as under:
    Output type: PDF
    [9/21/10 2:17:12 PM] [UNEXPECTED] [388056:RT14415347] java.io.FileNotFoundException: /app/soft/test1udp/appsoft/inst/apps/e180r_erptest01/logs/appl/conc/out/o14415347.out (No such file or directory)
         at java.io.FileInputStream.open(Native Method)
         at java.io.FileInputStream.<init>(FileInputStream.java:106)
         at oracle.apps.fnd.cp.opp.XMLPublisherProcessor.process(XMLPublisherProcessor.java:241)
         at oracle.apps.fnd.cp.opp.OPPRequestThread.run(OPPRequestThread.java:172)
    Report Builder 10g
    BI Publisher's version : 4.5.0
    RDBMS Version : 10.2.0.4.0
    Oracle Applications Version : 12.0.6
    Searched for the same on metalink and found Article ID 862644.1, other than applying patch and upgrading version of BI Publisher is there any other workaround to display a comma seperated string as long as 60k characters, If any please suggest.
    Thanks,
    Bhoomika

    Metalink <Note:1076529.6> extracts
    Problem Description
    When running a *.REP generated report file you get errors:
    REP-00002 Unable to retrieve string from message file
    REP-01439 Cannot compile program since this is a runtime report
    Running the same report using the *.RDF file is successful.
    You are running the report with a stored procedure,
    OR you are running against an Oracle instance other than the one developed on,
    Or, you recently upgraded your Oracle Server.
    Solution Description
    1) Check that the user running the report has execute permissions on any stored
    SQL procedures called. <Note:1049458.6>
    2) Run the report as an .RDF not an .REP , that is remove or rename the .REP
    version of the report. <Note:1012546.7>
    3) Compile the report against the same instance it is being run against.
    <Note:1071209.6> and <Note:1049620.6>

  • How can I extract high and low parts of a string that represents a 64bits decimal number?

    I want to extract the high and low parts to interpret it and convert to binary code, but such a hugh number (represented by a string) isn't easy to extract from the string directly its high and low parts.

    LabVIEW can't handle a 64-bit integer. You will have to store it as two 32-bit integers. If you need exact math on those 64-bit intergers you will have to make up your own routines to handle the carries and what not. If you just need pretty good accuracy, covert both 32-bit integers to double, multiply the upper 32-bit number by 2*32 (also a double) and then add the lower 32-bit number to it.
    Good luck.

  • Retrieving Strings from Database query ??

    Hi,
    The problem i'm having at the moment is, with the following code:
    connect = DriverManager.getConnection("jdbc:mysql://ash.bc.ic.ac.uk/KEGG_devel?user=null&password=guest");
    Statement stmnt1 = connect.createStatement();
    ResultSet rs1 = stmnt1.executeQuery("SELECT DISTINCT A.ReactID, A.ECid FROM ECReact As A INNER JOIN ECReact As B ON A.ECid = B.ECid AND A.id <> B.id ");
    System.out.println("the size of rs1 is: " +rs1.getFetchSize());
    while (rs1.next()){
    String reactionId = rs1.getString("ReactID");
    String ecNumb = rs1.getString("ECid");
    System.out.println("the value of ecNumb is :" +ecNumb);
    I want to be able to retrieve a String from the query called ECid - an example of such a String would be 4.2.1.86 or 4.2.1.44. However, when i'm Storing the "ECid" in a String called ecNumb and then printing the String all that i get returned is the last 2 digits !
    Does anyone know how to resolve this ??
    Thanks very much for any help
    (oh yeah + for future reference, how do i highlight code in topics??)

    to highlight code... isSimple...
    [bold] [ code][bold]
    your code pasted in here
    [bold] [ / code][bold]
    but leave out the spaces in the []
    i had to add them to get [ c o d e ] to show up.
    m.

  • Reconstructing a string from a database retrieval

    What is the correct way to retrieve data such as a string from a database? If I inputing data to the database like this...
    std::string inputString = "hello world";
    data.data = &inputString;
    data.size = inputString.size();
    ret = dbp->put(dbp, NULL, &key, &data, DB_NOOVERWRITE);
    and retrieving it like this...
    ret = dbp->get(dbp, NULL, &key, &data, 0);
    what do I need to do with 'data' to recover my string?
    std::string outputString = ??????;
    Thanks in advance.

    I'm using c++, just didn't realize that there was a db_cxx.h. I still have the same problem though. Here is my test code...
    #include <sys/types.h>
    #include <stdio.h>
    #include <string.h>
    #include <db_cxx.h>
    #define DATABASE "access.db"
    int main()
         Db db(NULL,0);
         int ret;
         db.open(NULL, DATABASE, NULL, DB_BTREE, DB_CREATE, 0);
         std::string KEY = "THE KEY";
         std::string DATA = "THE DATA: A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z";
         Dbt key(&KEY, KEY.length());
         Dbt dataIn(&DATA, DATA.length());
         if((ret = db.put(NULL, &key, &dataIn, DB_NOOVERWRITE)) != 0)
              db.err(ret, "DB->put");
         Dbt dataOut;
         if((ret = db.get(NULL, &key, &dataOut, 0)) != 0)
              db.err(ret, "DB->get");
         std::string outStr = *(std::string *)dataOut.get_data();
         std::cout << outStr.c_str() << std::endl;
         if((ret = db.close(0)) != 0)
              db.err(ret, "DB->close");
         return 0;
    If I run this twice, the first time through everything behaves as I believe it should. The database gets created and the output is "THE DATA: A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z". However, the second time I run it, 'put' returns an error due to an existing identical key/data pair (as it should), but the string is just junk as if the pointer is not pointing to the correct memory location. Since 'put' returned the appropriate error message, I expect that the database is fine, and the problem is somewhere in the 'get' function or conversion back to a string. Any ideas?

  • STARTED IT, BUT STILL NEED HELP -- INPUTTTING CHARACTERS FROM LOADED FILE INTO TABLE, SELECTING STRINGS FROM TABLE AND PLACING IN NEW TABLE, SAVING NEW TABLE TO SPREADSHEET FILE

    I AM TRYING TO IMPORT CHARACTERS FROM A TAB DELIMITED FILE INTO A TABLE ON LABVIEW.  ONCE THE DATA IS IN THE TABLE I WANT TO BE ABLE TO SELECT INDIVIDUAL STRINGS FROM THE TABLE AND PLACE IT IN A NEW TABLE.  WHEN I CLICK ON A STRING I WOULD LIKE THE SELECTED STRING TO SHOW IN A TEXT BOX LABELED 'SELECTED STEP'  AFTER ALL THE SELECTED STRINGS IS IN THE TABLE I WOULD LIKE TO SAVE THE NEW TABLE AS ANOTHER SPREADSHEET -- TAB DELIMITED -- FILE, MAKING IT ACCESSIBLE TO OPEN.  HERE IS WHAT I HAVE SO FAR.  I CAN INPUT DATA INTO THE TABLE, BUT I CAN ONLY TRANSFER ONE STRING INTO THE TABLE I WOULD LIKE TO BE TO INPUT MULTIPLE STRINGS.    ALSO WHENEVER I TRY SAVING THE FILE, IT ALWAYS SAVES A UNKNOWN FILE, HOW CAN I GET IT TO SAVE AS A SPREADSHEET FILE.  THANKING ALL OF YOU IN ADVANCE FOR YOUR HELP!!!!!!
    Attachments:
    Selector.zip ‏30 KB

    Pondered,
       The question you are asking is the same one that you asked in: http://forums.ni.com/ni/board/message?board.id=170&message.id=132508#M132508, to which I supplied a revised version of the original vi you used (which was modified from the original one I supplied to an earlier thread). A couple of questions: 1) What does my latest not do that is in your question, 2) Why are you starting yet another thread about the same problem?  We are here trying to help, it makes it a lot easier if you keep the same problem in the same thread, it reduces duplication of effort from those that might not have been following the previous thread(s).  Those of us that don't have our "names in blue" are just doing this "for fun" (the blue names are NI employees, who may still be doing it "for fun"), and it makes it more fun if it doesn't seem (correctly or not) that our attempts are ignored.  If an answer doesn't help, or seems incomplete, post a little more detail to the same thread so that the original respondent, or someone new, can provide more information, or understand your problem better.
    P.M.
    Message Edited by LV_Pro on 07-20-2005 01:20 PM
    Putnam
    Certified LabVIEW Developer
    Senior Test Engineer
    Currently using LV 6.1-LabVIEW 2012, RT8.5
    LabVIEW Champion

  • How to design and implement an application that reads a string from the ...

    How to design and implement an application that reads a string from the user and prints it one character per line???

    This is so trivial that it barely deserves the words "design" or "application".
    You can use java.util.Scanner to get user input from the command line.
    You can use String.getChars to convert a String into an array of characters.
    You can use a loop to get all the characters individually.
    You can use System.out.println to print data on its own line.
    Good luck on your homework.

  • Hello i need a help about script to export translatable text strings from ai files and import them back

    Hello i need a help about script to export translatable text strings from ai files and import them back after editing, thanks in advance

    Lanny -
    Thank you for taking the time to help with this problem. Can I just say however that as someone who has posted a first comment here and quite clearly never used a forum like this before, your comment unfortunately comes across as very excluding. It makes me feel there are a set of unwritten rules that I should know, and that I don't know them shows that the forum is not for me. In short, it's exactly the kind of response that stops people like me using forums like this.
    I'm sure it's not intended to be received like this and I am sure that the way you have responded is quite normal in the rules of a forum like this. However, it is not normal for those of us who aren't familiar with forums and who only encounter them when they have a genuine problem. This is why I hope it is helpful to respond in full.
    The reason I posted here is as follows. I was directed here by the apple support website. The original comment seemed to be the only one I could find which referred to my issue. As there is no obvious guidance on how to post on a forum like this it seemed perfectly reasonable to try and join in a conversation which might solve more than one problem at once.
    Bee's reply however is both helpful and warm. This could in fact be a template for how new members should be welcomed and inducted into the rules of the forum in a friendly and inclusive way. Thank you very much indeed Bee!

  • Error while trying to retrieve string from STDIN

    Hello,
    I want to read a string from input I use this code but getting compilation error:
    String s = System.in.readLine();
    Error is:
    symbol : method readLine ()
    location: class java.io.InputStream
    String s=System.in.readLine();
    ^
    1 error
    what's going wrong?
    System is Linux Slackware 9.1
    Thanks,
    Regards.

    Yeah, don't use readLine if you just want a single character. Actually you don't need the BufferedReader at all unless you want to do buffering for a reasoon other than to make it easy to read a line at a time. (Of course, buffering is a good thing anyway, but it's not strictly relevant to grabbing a character.)
    Re: requiring enter to be pressed, that may have a lot to do with your shell as well.
    try {
      Reader in = new InputStreamReader(System.in);
      int theChar; // you need an int because the read method returns values
                   // beyond the bits required for a char, to denote end of file
      while((theChar = in.read()) > -1) {
        System.out.println("Char read: " + (char) theChar);
      System.out.println("end of file reached");
    } catch (IOException e) {
      e.printStackTrace();
    }

Maybe you are looking for