Converting sed regex to Java regex

I am new to reguler expressions.I have to write a regex which will do some replacements
If the input string is something like test:[email protected];value=abcd
when I apply the regex on it,this string should be changed to test:[email protected];value=replacedABC
I am trying to replace test.com and abcd with the values i have supplied...
The regex I have come up with is in sed
s/\(^.*@\)\(.*\)$/\1replaceTest.com;value=replacedABC/i
Now I am trying to get the regex in Java,I would think it will be something like (^.*@\)(.*\)$\1replaceTest.com;value=replacedABC
But not sure How i can test this.Any idea on how to make sure my java regex is valid and does the required replacements?

rsv-us wrote:
Yep.Agreed.
Since that these replacements should be done in a single regex.Note that the sed replacement I posted is really made of two replacements! Just like your Java solution would.
I think once we send this regex to the third party,they will haev to use either sed or perl(will perl do this replacements,not sure though) to get the output.
Since we are not sure what tool/software the third party is going to use,I was trying to see how i can really test this.Then I read about sed and this regex as is didn't work,so,I had to put all the sed required / and then the regex had become like s/\(^.*@\)\(.*\)$"/1replaceTest.com;value=replacedabcd/iAgain: AFAIK that does not work. I tried it like this:
{code}$ echo test:[email protected];value=abcd | sed 's/\(^.*@\)\(.*\)$"/1replaceTest.com;value=replacedabcd/i'and the following is returned:test:[email protected] that we will have to send the java regex to the third party,I was trying to see how i can convert this sed regex to java.If I am right,with jave regex,we won;t be able to all the finds and replacements in a single regex..right?...If this is true,this will leave me a question of whether I need to send the sed regex to the thrid party or If I send java regex,they have to convert that to either sed or perl regex.
One more question,can we do thse replacement in perrl also,if so,what will the equivalent regex for this in perl?
I can't understand what you are talking about. The large amount of spelling errors also doesn't help to make it clearer.
Good luck though.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • Sed rules to java regex

    Hi,
    what is the connection between sed regex rules and java regex rule. Is there an easy way to convert sed to java? or do i have to learn sed?....
    Thanks

    IIRC, Java regex rules are like Perl's (although the syntax for invocation differs a bit), and Perl's are basically a superset of sed's, except there's a difference with parentheses. In Perl/Java, parentheses always group and you have to backslash-quote them to make them interpreted as plain parenthesis characters, whereas in sed, you backslash-quote them to make them be interpreted as grouping indicators.
    Why? What problem are you having?

  • Cannot convert ÿØÿà of type class java.lang.String to class BFileDomain.

    Hi All,
    I am using Jdeveloper 11.1.2.3.0.
    I have a scenario of making an ADF page where I have a IMAGE field to show on the page. So,I have a table called "PRODUCT" with fields called photo with BFILE type. Now when I the data i have inserted using the DML command and i can see the path at the backend.
    However,when i am runnig my ADF page in the Filed called "PHOTO" I can only see a junk character stating 'yoyo'.
    When I click on it, it says ERROR "Cannot convert ÿØÿà of type class java.lang.String to class oracle.jbo.domain.BFileDomain".
    Your help will be appreciated ASAP.
    Regards,
    Shahnawaz

    Hi,
    did you show the id-value in the user interface as a input-component, and did the input-component include a converter?
    If yes, show the id as output-text and remove any existing converter-components.
    Best Regards

  • How to convert dll to a java class file?

    Hi folks:
    I have some DLLs in VB and C++ and I wanna to convert them to a java class file. Does anybody know if exist a sw or easy way to do it?
    thanks
    Autair

    Well, I believe you could write JNI to call the functions in the DLLs, although I wouldn't recommend it. (You'd have a non-portable, fragile result.)

  • How to convert .class files to .java files

    Hi,
    I want to convert .class files to .java files. Is there is any software for that doing except Dj DCompiler? Because if i am using this i am not getting proper code i mean as it is available in the file.
    I tried by writing simple java file and i compiled Sample.java file and i got a .class file then i converted this Sample.class to Sample.java file by using DjDcompiler but i was missing some statements i need entire code that is available in Sample.java file. Please tell me any other software for that doing.
    Thank you in advance

    I want to convert .class files to .java files.
    iles. Is there is any software for that doing except
    Dj DCompiler? Because if i am using this i am nothttp://www.google.com/search?hl=en&q=java+decompiler&meta=
    getting proper code i mean as it is available in the
    file.I doubt you ever will.
    I tried by writing simple java file and i compiled
    Sample.java file and i got a .class file then i
    converted this Sample.class to Sample.java file by
    using DjDcompiler but i was missing some statements i
    need entire code that is available in Sample.java
    file. Please tell me any other software for that
    doing.Did you hear about "compiler opimizations"?

  • How to convert oracle timestamp to java timestamp

    Hi,
    I need to convert oracle timestamp that i got from oracle database to java timestamp.I tried to use getTimestamp() to get timestamp value from oracle, but am getting NumberFormatException.
    Could any of suggest how to convert oracle timestamp to java timestamp.

    Thanks jverd ,
    then my code will be like:
    String oracleTS="11-MAR-05 11.19.20.625 AM";
    // am looking for yyyy-MM-dd HH:mm:ss format
    SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd
    HH:mm:ss");           
    Timestamp javaTimestamp=Timestamp.valueOf(oracleTS);
    System.out.println("javaTimestamp----->>
    "+javaTimestamp);
    ving java.lang.NumberFormatException: For input
    string: "MAR"Well, the SimpleDateFormat has to actually match the format you're trying to parse, for one thing. Then you have to actually USE the SDF, which you didn't.
    You really haven't made it clear what you're trying to do, and it doesn't appear that you bothered to study the links I provided.
    DateFormat df = new SimpleDateFormat("dd-MMM-yy HH.mm.ss.SSS aa");
    Date date = df.parse(oracleTS);
    Timestamp ts = new Timestamp(date.getTime());

  • Convert a String to java.sql.Date Format

    Hi,
    I am having a String of containing date in the format 'dd/mm/yyyy' OR 'dd-MMM-YYYY' OR 'mm-dd-yyyy' format. I need to convert the string to java.sql.Date object so that I can perform a query the database for the date field. Can any one suggest me with the code please.
    Regards,
    Smitha

    import java.text.SimpleDateFormat;
    import java.text.ParseException;
    import java.util.Date;
    public class TestDateFormat
         public static void main(String args[])
              SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
              System.out.println(sdf.isLenient());
              try
                   Date d1 = sdf.parse("07-11-2001");
                   System.out.println(d1);
                   Date d2 = sdf.parse("07:11:2001");
                   System.out.println(d2);
              catch(ParseException e)
                   System.out.println("Error format, " + e);
    See class DateFormat and SimpleDateFormat for detail.

  • Convert SQL statements to JAVA Code ?

    Using SQL queries Can I convert SQL statements to JAVA Code ?
    Edited by: user11238895 on Jun 7, 2009 10:54 PM
    Edited by: user11238895 on Jun 7, 2009 11:12 PM

    Me very new to Oracle.
    can we convert SQL Queries to JAVA Code using simple built in SQL queries ?
    Which SWISS SQL Tool does [Converting SQL Queries to JAVA Code]

  • Error converting CF int to JAVA long

    Hi,
    I am calling a java method in my code that expects a
    parameter of type long (64 bit).
    If I pass a large int from ColdFusion (i.e. 10000000000) I
    get the following error:
    Could not convert the value 1.0E10 to an integer because it
    cannot fit inside an integer.
    I understand that CF integers are 32 bit so I tried to use
    the javacast function as follows:
    TestPaymentVO.setTestAmount(javacast("long", form.testAmt);
    but I still get the same error.
    Is there ANY way past this????
    Any help would be much apprecieated.
    Thanks.

    Ran into the JavaCast-long problem a while ago & then
    wrote the following article:
    http://kuhn.cf-workshop.de/CF_BUGS/JavaCast_long.htm
    Don't really see a general solution though, my solutions were
    either to call another function (int-input) or write pieces of code
    in java to handle the long-datatype there.
    For ex. a java-function reveiving a string, converting the
    string to java-long, then calling the desired java-function.

  • Converting oracle forms into java forms

    Hi all,,
    would help me plz on how to convert oracle forms into java using any tool;
    Is Jheadstart is the tool,, im having jeveloper version 10.1.2.1.0

    There are at least two companies that are marketing Forms to Java conversion tools. I'm sure that a good Google search will locate them, and they are frequent exhibitors at Oracle-oriented conferences like Collaborate and ODTUG Kaleidoscope. But there are problems associated with doing this. I urge anyone who is considering such a project to read this article by Grant Ronald: http://www.oracle.com/technology/products/forms/pdf/10gR2/formsmigration.pdf
    You should carefully ask yourself and your clients and management, "Why do you want to do this?", "What benefits are you trying to realize?", "Does this make sense, and are there other options that we should be exploring?"
    For instance, many people are trying to protect themselves because "Forms is going away". Oracle has stated again and again that Forms is NOT going away. In fact the recent Fusion Middleware 11g release included a new version of Forms with some significant enhancements. You may do very well just by upgrading to the latest version of Forms.
    If you do decide that it still makes sense to convert, I suggest that rather that converting, you may want to redevelop from scratch. Keep the database if it is well designed - a well designed, stable database will outlast any front end that you may use against it. Then take full advantage of the capabilities of your new toolset, and leave behind the limitations and inapplicable methodologies of your old one. Oh, by the way, don't use JDeveloper 10.1.2. Use 11g if you can, or 10.1.3.5 if you must.

  • How to convert class files into java files??

    Hey Guys,
    I need a little help.
    I want to know wheather we can view .class files as .java files or convert the .class to .java files.Is ther any tool or software for doing that.
    Or in other words can i see the source code of any .class file..??
    Plz do tell me if we can do that or any other way we can do that.
    Regds,
    Gokul

    Sort of. A "decompiler" will take a class file and generate a source code file of source code that could be compiled to get the class file you started out with. However, it won't be the same source code that was originally used to create the class. Most notably, comments will be missing, and variable names will probably be meaningless.
    And before you say "java is bad because you can decompile it", note that any language that you can execute you can theoretically decompile.
    Also, you can view the raw byte codes. If you're familiar with assembly language, or better yet familar with java bytecodes and the JVM in particular, you can often find out what a particular method does just by viewing the byte codes.

  • How to convert Property files into Java Objects.. help needed asap....

    Hi..
    I am currently working on Internationalization. I have created property files for the textual content and using PropertyResourceBundles. Now I want to use ListResourceBundles. So what I want to know is..
    How to convert Property files into Java Objects.. I think Orielly(in their book on Internationalization) has given an utitlity for doing this. But I did not get a chance to look into that. If anyone has come across this same issue, can you please help me and send the code sample on how to do this..
    TIA,
    CK

    Hi Mlk...
    Thanks for all your help and suggestions. I am currently working on a Utility Class that has to convert a properties file into an Object[][].
    This will be used in ListResourceBundle.
    wtfamidoing<i>[0] = currentKey ;
    wtfamidoing<i>[1] = currentValue ;I am getting a compilation error at these lines..(Syntax error)
    If you can help me.. I really appreciate that..
    TIA,
    CK

  • How to convert csv files into java bean objects?

    Hi,
    I have a CSV file, I want to store the data availabale in that csv file into java bean, I am new to this csv files how can I convert CSV files into java beans.
    Please help me.
    Adavanced Thanks,
    Mahendra

    You can use the java.io API to read (and write) files. Use BufferedReader to read the CSV file line by line. Use String#split() to split each line into an array of parts which were separated by comma (or semicolon). If necessary run some escaping of quotes. Finally collect all parts in a two-dimensional List of Strings or a List of Javabeans.
    java.io API: [http://www.google.com/search?q=java.io+javase+api+site:sun.com]
    java.io tutorial: [http://www.google.com/search?q=java.io+tutorial+site:sun.com]
    Basic CSV parser/formatter example: [http://balusc.blogspot.com/2006/06/parse-csv-upload.html]

  • Convert C++ prog into Java( I m new in java)help urgent

    hi all,
    i am very new in java. i have code of C++.i have to convert it in to Java.please help me on urgent basis.plz provide me solution.
    I am looking for positive response.code is below:
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <sys/stat.h>
    #include <fstream.h>
    #include <iostream.h>
    //#include <sha.h> //24112003
    //#include<wincrypt.h>
    char ntc(unsigned char n){
    if (n<26) return 'A'+n;
    if (n<52) return 'a'-26+n;
    if (n<62) return '0'-52+n;
    if (n==62) return '+';
    if (n==63)return '/';
    unsigned char ctn(char c){
    if (c=='/') return 63;
    if (c=='+') return 62;
    if ((c>='A')&&(c<='Z')) return c-'A';
    if ((c>='a')&&(c<='z')) return c-'a'+26;
    if ((c>='0')&&(c<='9')) return c-'0'+52;
    if (c=='~') return 80;
    return 100;
    int b64decode(char from,char to,int length){
    unsigned char c,d,e,f;
    char A,B,C;
    int i;
    int add;
    char *tot=to;
    for (i=0;i+3<length;){
    add=0;
    A=B=C=0;
    c=d=e=f=100;
    while ((c==100)&&(i<length)) c=ctn(from[i++]);
    while ((d==100)&&(i<length)) d=ctn(from[i++]);
    while ((e==100)&&(i<length)) e=ctn(from[i++]);
    while ((f==100)&&(i<length)) f=ctn(from[i++]);
    //if (f==100) return -1; /* Not valid end */
    if (c<64) {
    A+=c*4;
    if (d<64) {
    A+=d/16;
    B+=d*16;
    if (e<64) {
    B+=e/4;
    C+=e*64;
    if (f<64) {
    C+=f;
    to[2]=C;
    add+=1;
    to[1]=B;
    add+=1;
    to[0]=A;
    add+=1;
    to+=add;
    if (f==80) return to-tot; /* end because '=' encountered */
    return to-tot;
    int b64get_encode_buffer_size(int l,int q){
    int ret;
    ret = (l/3)*4;
    if (l%3!=0) ret +=4;
    if (q!=0){
    ret += (ret/(q*4));
    /* if (ret%(q/4)!=0) ret ++; */ /* Add space for trailing \n */
    return ret;
    int b64strip_encoded_buffer(char *buf,int length){
    int i;
    int ret=0;
    for (i=0;i<length;i++) if (ctn(buf)!=100) buf[ret++] = buf [i];
    return ret;
    int b64encode(char from,char to,int length,int quads){
    // 3 8bit numbers become four characters
    int i =0;
    char *tot=to;
    int qc=0; // Quadcount
    unsigned char c;
    unsigned char d;
    while(i<length){
    c=from[i];
    *to++=ntc(c/4);
    c=c*64;
    i++;
    if (i>=length) {
    *to++=ntc(c/4);
    *to++='~';
    *to++='~';
    break;
    d=from[i];
    *to++=ntc(c/4+d/16);
    d=d*16;
    i++;
    if (i>=length) {
    *to++=ntc(d/4);
    *to++='~';
    break;
    c=from[i];
    *to++=ntc(d/4+c/64);
    c=c*4;
    i++;
    *to++=ntc(c/4);
    qc++; /* qz will never be zero, quads = 0 means no linebreaks */
    if (qc==quads){
    *to++='\n';
    qc=0;
    /* if ((quads!=0)&&(qc!=0)) to++='\n'; / /* Insert last linebreak */
    return to-tot;
    char* mEncryptPassword(char* mPassword)
    char mEncryptedPassword[200]; // To hold encrypted password.
    //char* mEncryptedPassword = new char[200];
    char mPrimEncryptedPassword[200];
    char * temp = new char[200];
    //unsigned char* md; // 19122003
    //md = new unsigned char[100]; // 19122003
    memset(mEncryptedPassword, '\0', sizeof(mEncryptedPassword));
    memset(mPrimEncryptedPassword, '\0', sizeof(mPrimEncryptedPassword));
    strcpy(mPrimEncryptedPassword, mPassword);
    //strcpy(mPrimEncryptedPassword, (char*) SHA1((unsigned char*) mPassword, strlen(mPassword), NULL));
    //strcpy(mEncryptedPassword, (char*) SHA((unsigned char*) mPassword, strlen(mPassword), md)); // 19122003
    //strcpy(mEncryptedPassword, (char*) SHA((unsigned char*) mPassword, strlen(mPassword), md)); //19122003
    b64encode(mPrimEncryptedPassword, mEncryptedPassword, strlen(mPrimEncryptedPassword), 0);
    // If successfully encrypts..
    if (mEncryptedPassword != NULL)
    //char * temp = new char[strlen(mEncryptedPassword)+1];
    strcpy(temp,mEncryptedPassword);
    // strcpy(mRetVal,mEncryptedPassword);
    return (char*)temp;
    //return (mEncryptedPassword);
    //return (char*) md; // 19122003
    else
    return ("Error");
    char* mDecryptPassword(char* mPassword)
    char mDecryptedPassword[200]; // To hold decrypted password.
    char mPrimDecryptedPassword[200];
    char * temp = new char[200];
    // 02032007
    memset(mDecryptedPassword, '\0', sizeof(mDecryptedPassword));
    memset(mPrimDecryptedPassword, '\0', 200);
    strcpy(mPrimDecryptedPassword, mPassword);
    b64decode(mPrimDecryptedPassword, mDecryptedPassword, strlen(mPrimDecryptedPassword));
    // If successfully decrypts..
    if (mDecryptedPassword != NULL)
    //char * temp = new char[strlen(mEncryptedPassword)+1];
    strcpy(temp,mDecryptedPassword);
    // strcpy(mRetVal,mDecryptedPassword);
    return (char*)temp;
    //return (mEncryptedPassword);
    //return (char*) md; // 19122003
    else
    return ("Error");
    void main(int argc, char* argv[])
    cout << mEncryptPassword(argv[1])<<endl<<flush;
    cout << mDecryptPassword(mEncryptPassword(argv[1]))<<endl<<flush;
    Anubhav

    endasil wrote:
    I just thought of how ridiculous this would sound in any other profession:
    Surgeons:
    plz plz help I have patient dying need to insert new kidney into 90yr old patient plz someone come do itLawyers:
    Help client guilty need good defense (I m new in law)help urgentHow come we get stuck with the lazy low-lifes?Because there's no legal requirement that a software developer must be licensed

  • Help! How to convert an instance from java.lang.Object to a particula class

    * How to convert an instance from java.lang.Object class to a particular class
    witch is known only at the running time?
    Roster EJB component is make up of RosterHome, Roster and RosterBean.
    RosterHome is the home interface of Roster EJB.
    Roster is the remote interface of Roster EJB.
    RosterBean is the implement of Roster EJB.
    The following code segment is to invoke Roster EJB component.
    String jndiName="roster.RosterHome";
    javax.naming.Context initial = getInitialContext();//getInitialContext() returns a instance of Context.
    Object objref = initial.lookup(jndiName);
    RosterHome home =
    (RosterHome)javax.rmi.PortableRemoteObject.narrow(objref,
    RosterHome.class);
    Roster myRoster = home.create();
    String team="T1"
    String player="Tom"
    myRoster.addPlayer(player,team);
    But, now, all the home interface, the remote interface and the JNDI Name of
    Roster EJB component are not been known at the compiling time. However They are
    known at the running time, throught reading from the XML config file.
    Questions:
    1,How to write code for this case ? or
    2,How to convert an instance from Object class to a particular class witch is known
    only at the running time?
    String jndiName="roster.RosterHome";// in fact, reads from XML file.
    String homeClassName="roster.RosterHome";// in fact, reads from XML file.
    String remoteClassName="roster.Roster";// in fact, reads from XML file.
    javax.naming.Context initial = getInitialContext();//getInitialContext() returns a instance of Context.
    Object objref = initial.lookup(jndiName);
    Object objHome= javax.rmi.PortableRemoteObject.narrow(objref,
    Class.forName(homeClassName));
    /* how to do next?
    }

    I am not sure what you are trying to do. But at some point you should know which methods to call on the remote interfaces. Maybe the method names are stored in the XML file as well or you have a set of standard method names (also consider parameters).
    However, this can be solved by reflection. Look at the java.lang.reflect package, especially java.lang.reflect.Method, and also at java.lang.Class.
    If you are doing this on the app server:
    I've seen posts where people say that reflection is not permitted in EJB, but I don't think so. Check the EJB spec.
    If you are doing this in an application: reflection is always permitted. Probably also in applets and JSP.

Maybe you are looking for