How do we compare a complex string?

Hi guys,
how do i compare the following strings
input_Variable: User-agent : *
if i want to ensure that the input_variable has "User-agent" and the character '*'.
There are 3 possiblities for input_variable:
1) User-agent: *
2) disallow: http:///xxxxxxxxxxxx
3) User-agent:Somename
The white space between the words could be uneven and same goes with the character case.
thanks,
Derik

Hi.. Derik
How about this one..
String input_Variable = "[from your input method]";
if ( input_Variable.indexOf("User-agent") != -1
&& input_Variable.indexOf("*") != -1 )
System.out.println("yeah.. authorized..");
indexOf(String str) method returns -1 when it can't find out a specific string from the source string..

Similar Messages

  • How to compare 2 version strings (of the format x.x.x.x where x : {0, 99})

    I am using Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production,
    PL/SQL Release 11.2.0.2.0 - Production
    I have a scenario like:
    Table1:
    Name Null Type
    NAME NOT NULL VARCHAR2(64)
    VERSION NOT NULL VARCHAR2(64)
    Data:
    Table1
    Name Version
    A 1
    B 12.1.0.2
    B 8.2.1.2
    B 12.0.0
    C 11.1.2
    C 11.01.05
    I want the output as:
    Name Version
    A 1
    B 12.1.0.2
    C 11.01.05
    Basically ,I want to get rows for each name which having highest version. For this i am using following query:
    SELECT t1.NAME,
    t1.VERSION
    FROM TABLE1 t1
    LEFT OUTER JOIN TABLE1 t2
    on (t1.NAME = t2.NAME and t1.VERSION < t2.VERSION)
    where t2.NAME is null
    Now 't1.VERSION < t2.VERSION' only works in normal version cases but in cases such as:
    B 12.1.0.2
    B 8.2.1.2
    It fails, So i want a PL/SQL script to normalize the version strings and compare them for higher value.

    Hi,
    Here's one way:
    ORDER BY  REGEXP_REPLACE ( REGEXP_REPLACE  ( version
                                           , '(\d+)'
                                , '0000\1'
                    , '0+(\d{5})'
                    , '\1'
                    )This assumes that you never have more than 5 digits in a row. You can easily change that to any fixed number.
    This will not cause an error if you have letters or other symbols in the string.
    This makes no assumptions about how many numbers are in the string, or what characters delimit the numbers.
    Here's how it works:
    The inner REGEXP_REPLACE adds 4 '0's immediately before any substring of digits. This guarantees that all numbers are at least 5 digits long.
    The outer REGEXP_REPLACE removes '0's from the beginning of numbers that are more than 5 digits long, which guaranteees that the numbers will be exactly 5 digits long. '00008' will come before '00012'

  • How can I compare the actual and expected values in Unit testing when they are XML files?

    I have created a unit test for a method in VS 2008. My expected value and actual value are XMLs. Therefore though the output is same as I expect it gives an error as I am doing string comparison now. How can I compare these 2 XMLs in expected output and
    actual output format in Unit Testing?
    mayooran99

    In unit test, when you want to validate XML files, you feed them into the class / struct that you want to feed the XML into and compare the values there (You don't just feed it in XMLReader and feed it line by line, right? But if it really is, that's how
    you should also test it in unit tests).
    In short, how you'd use the XML in your code, that's how you should test it in unit test.

  • I would like to know how can i compare a switch case 1 and case 2 in C# is it possible to do that? obs i am a begginer :)

    i would like to know how can i compare a switch case 1 and case 2 in C# is it possible to do that? obs i am a begginer :) I tried to do it with search and sort but it did not go well

    let me give you an example if you add a word case 1( lagg ord) how can i compare that word with case 2 words ( in case 2  already exist 5 words)
    here is the my program 
    using System;
    namespace ConsoleApplication1
        class Program
            static void Main(string[] args)
                //Meny
                Console.WriteLine("\n HÄNGA GUBBE\n");
                Console.WriteLine(" 1) Lägg till ord");
                Console.WriteLine(" 2) Lista alla ord");
                Console.WriteLine(" 3) Spela");
                Console.WriteLine(" 4) Avsluta");
                bool utgång = false;
                do
                    int Valet;
                    Console.Write("\n\tVälj 1-4: \n ");
                    try
                        Valet = int.Parse(Console.ReadLine());
                    catch (Exception)
                        Console.WriteLine("Du skriver fel character!\n" +
                            "\nSkriv bara mellan 1 och 4");
                        continue;
                    switch (Valet)
                        case 1:
                            Console.WriteLine("\n lägg ett till ord! ");
                          var input = Console.ReadLine();
                            break;
                        case 2:
                            Console.WriteLine("\n Lista med alla ord :\n");
                            string[] array = { " Lev", " Skratta", " Gledje", " Gråt", " Njut" };
                            Array.Sort<string>(array);
                            foreach (var c in array)
                                Console.WriteLine(c);
                            Console.WriteLine("\n");
                            break;
                        case 3:
                            string guesses, bokstäver;
                            Console.Write("\n Hur många fel får man ha? ");
                            guesses = (Console.ReadLine());
                            Console.WriteLine(" Utmärkt, då spelar vi!\n");
                            Console.WriteLine(" Felgisningar :" + "0/" + guesses);
                            Console.Write(" Gissade bokstäver ");
                            bokstäver = (Console.ReadLine());
                            Console.WriteLine("Aktuellt ord");
                            Console.Write("Gissa bokstav : " + bokstäver + " \n");
                            break;
                        case 4:
                            Console.WriteLine("\n  HEJ DÅ! \n");
                            Console.Beep();
                            utgång = true;
                            break;
                        //avbryter while loopen, avslutar spelet
                } while (!utgång);

  • How can I compare two summary field in cross-tab?

    <p>Dear expert:</p><p>I have one question for how can I compare two summary field in cross-tab?  I have following cross-table:</p><p>Type          Sector1     Sector2    Sector3       Total </p><p>Outlook         10            11           9              30         </p><p>Target            5              3           1               9</p><p>I want to compare the summary field(total) relationship percent, I want to get "9/30". Someone told me I must create the DB view or table via SQL, then can implete in Crystal Report. Can I implete it in Crystal Report via fomula or other function?</p><p>Thanks so much for your warm-hearted help!</p><p>Steven</p>

    Hello Steven, yes you can compare summary fields, If you are comparing Summary to Target, or vice versa - you can do it within Crystal Reports.
    1. In Suppress conditional formula, create 2 Global variables: CurrentOutlook and CurrentTarger and get the current value.
    2. In Display String formula for Total show ToText(CurrentTarget/CurrentOUtlook) + "%".
    For more difficult cases of compariing fields in cross--tab, you may look into http://www.relasoft.net/KB10001.html.
    Best,
    Alexander

  • How to sort a list of strings, without methods and stuff just simple code?

    Hi
    How to sort a list of strings, without methods and stuff just simple code?
    Thanks in adavance!!

    Without methods? How are you going to all the sort code? What is the point of code?
    Collections.sort(List) will sort strings or anything that implements the Comparable interface, or you can use the sort method that takes a Comparator implemenation.
    If you want "just code", you could either get the Collections class souce and follow it to the code. But otherwise, there isn't one set of code. There are various sorting algorithms with advantages and disadvantages. Maybe you'd be better off searching for sorting algorithms and if you understand them, it should be simple to write Java implementations of them.

  • How do i compare value javascript variable with jsp variable

    I have promblem .I have variable that store store the attribute value of column .The colum has more then one value.How to i compare with javascript value .Currently I am using the following method .
    <%String sql_query3 = "SELECT DISTINCT (ir_tran_typ),ir_rea_desc "+
                                              "  FROM intrcd "+
                                              " GROUP BY ir_tran_typ ";
                               System.out.println("trans type"+sql_query3 );           
                                try{
                                    rset = db.execSQL(sql_query3);
                                catch(SQLException e) {
                                    System.err.println("Error in query - intrcd - transaction_main.jsp " +e +" sql " +sql_query3);
                                while(rset.next()== true){
                                    tran_cde = rset.getString("ir_tran_typ");
                                            rea_desc = rset.getString("ir_rea_desc");%>
                                            <%System.out.println("trans type 34 "+tran_cde );%>
                                                 //tran_typ = addElement('<%=tran_cde%>');
                                                 <% }%>
                                      if(obj.value== '<%=tran_cde%>' ){      
    <%                                 String sql_query2 = "SELECT ir_rea_cde,ir_rea_desc"+
                                              "  FROM intrcd"+
                                              " WHERE ir_tran_typ = '"+tran_cde+"' " +
                                                        " ORDER BY ir_rea_cde ";
                               System.out.println("trans type"+ tran_cde);           
                                try{
                                    rset = db.execSQL(sql_query2);
                                catch(SQLException e) {
                                    System.err.println("Error in query - emmast2 - transaction_main.jsp " +e +" sql " +sql_query2);
                                        index = 1;
                                while(rset.next()== true){%>
                                document.all.rea_cde.options[<%=index%>] = new Option(eval('"<%=rset.getString("ir_rea_cde")%>"'));
                                document.all.rea_cde.options[<%=index%>].value = eval('"<%=rset.getString("ir_rea_cde")%>"');
                                document.all.rea_cde.options[<%=index%>].text = eval('"<%=rset.getString("ir_rea_desc")%>"');
    <%                          index++;
                                       }%>
    please replay me soon
    thank you.

    javascript and java do not mix.
    Java code runs, and produces HTML/javascript.
    Java code stops running.
    The page loads in the browser, and it starts up javascript.
    Javascript cannot talk to java and vice versa.
    Your JSP can generate javascript code onto the page to be executed on the client, but they never directly communicate.
    please replay me soongame over dude ;-)

  • HT1209 My Itunes Library and iPhone have fallen out of sync on music over the yearsare - how can I compare my itunes library with my Iphone  to see what songs are missing from my library so I can then bring my Library up to date

    My Itunes Library and iPhone have fallen out of sync on music over the yearsare - how can I compare my itunes library with my Iphone  to see what songs are missing from my library so I can then bring my Library up to date

    Hello Solid Buck,
    Thank you so much for providing the details about the duplicate song issue you are experiencing.  It sounds like you would like to remove the duplicate songs that will not play on your iPhone, but when you connect it to iTunes, iTunes only shows you one copy of the song on your iPhone. 
    In this situation, I recommend deleting the individual songs that do not play directly from your iPhone.  I found the steps to do this on page 61 of the iPhone User Guide (http://manuals.info.apple.com/en_US/iphone_user_guide.pdf):
    Delete a song from iPhone: In Songs, swipe the song, then tap Delete.
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • How do I create a connection string to sql server?

    Hi All,
       I am currently connecting to a SQL Server via ODBC DSN connection. I am wondering how do I create a connection string directly to a sql server without a DSN connection?
    Thank you in advance.

    If you have SQL Server or client installed in your machine you can directly connect to SQL server using native connection. When you create new report you can see the option create new connection, here you can see SQL Server. Expand it and enter the connection details where you will be directly connected to SQL Server without ODBC connection.
    Regards,
    Raghavendra

  • 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

  • How can I compare more than two VIs at a same time in labview 2009

    How can I compare more than two VIs at the same time. I am an Lab Engineer I have to check assignments submitted by students and I want to know how many of them are copied from each other. Labview compare VI can only compare two VI at a time while I want to check about 30 VIs at same time.
    Regards,

    I'm not aware of a tool to compare multiple VIs.  If you don't find anything, consider posting this to the LabVIEW Idea Exchange to expose this idea directly to NI R&D.
    Thanks!
    - Greg J

  • How to read and write a string into a txt.file

    Hi, I am now using BEA Workshop for Weblogic Platform version10. I am using J2EE is my programming language. The problem I encounter is as the above title; how to read and write a string into a txt.file with a specific root directory? Do you have any sample codes to reference?
    I hope someone can answer my question as soon as possible
    Thank you very much.

    Accessing the file system directly from a web app is a bad idea for several reasons. See http://weblogs.java.net/blog/simongbrown/archive/2003/10/file_access_in.html for a great discussion of the topic.
    On Weblogic there seems to be two ways to access files. First, use a File T3 connector from the console. Second, use java.net.URL with the file: protocol. The T3File object has been deprecated and suggests:
    Deprecated in WebLogic Server 6.1. Use java.net.URL.openConnection() instead.
    Edited by: m0smith on Mar 12, 2008 5:18 PM

  • How to convert BLOB into a String

    Hi,
    I got a blob column from the database.
    It contains one XML File.
    How to convert it into String.
    I need the code for how to convert the blob into String
    Thanks in Advance.

    A blob would be a byte-array, which you can use in the String(byte[]) constructor

  • How can I display on a string the symbol omega (ohms)

    how can I display on a string the symbol omega (ohms)

    Hi,
    See there : http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=135&HOID=50650000000800000032410000&UCATEGORY_0=_49_%24_6_&UCATEGORY_S=0
    Hope this helps !
    Julien

  • How do you append to a "string" type field?

    ABAPers,
    I am trying to understand how to append values to a "string" data type in an efficient way. One way to append to a string is using "concatenate" feature.
    data: myRetVal type string.
    DO
      CONCATENATE myRetVal ',' myNewData INTO myRetVal.
    ENDDO.
    However, CONCATENMATE is not efficient in this scenario. Each time you call it, myRetVal gets copied into myRetVal all over. As the string grows, this statement will execute slower and slower.
    The other option I thought is to use offset mechanism.
    MOVE myNewData to myRetVal+myRetValLen.
    However, it appears "string" and "xstring" type fields do not support offset and length operations.
    Is there a third choice that I am missing?
    Thank you in advance for your help.
    Pradeep

    There is no such operator.
    But if just using literals, you can use the &, like this.
    data: string type string.
    string = 'This is the first part ' & 'This is the second part'.
    Again, this will not work with variables.
    Regards,
    Rich Heilman

Maybe you are looking for

  • My mac is a 10.5.8 what steps do I take to up grade? I have an iphone 5 and can't update my phone on itunes.

    My Mac OS X (10.5.8) what steps do I take to up grade? I have an iphone 5, and can't update my phone using itunes.

  • Unable to see IDOC sent by R3 in XI

    In XI server, we have done partner profile(ALE/IDOC) configuration due to some special requirement. Now XI server unable to receive the IDOC. After from this, I am unable to see the IDOCs that were processed earlier. Before this ALE/IDOC configuratio

  • [BUG]: MakeWritable doesn't work for mac

    I'm trying to use oracle.jdeveloper.refactoring.util.MakeWritableHelper in my plugin, and I found it doesn't work for MAC. The byte code shows it only check the osname for "Windows" and "Linux". and some Jdeveloper refactoring feature failed due to c

  • IPod not highlighted in iTunes for content editing

    I've got a Mac G4 using an OSX version 10.2.8 operating system. I just got a Nano iPod and am unable to transfer files to it. I've downloaded the most current available iPod drive and updates but after plugging it in, the iPod icon appears momentaril

  • Still dropping wifi on iMac after 8.1.1 updates

    Have been on a few service calls to Apple after installing Yosemite..as my IMac keeps dropping the wifi signal and is stubborn to rejoin..tells me my router is not recognized 15 times..before it accepts it..then drops it after sleep mode.  All other