How to compare 2 strings in batch

I have this code
for /l %%a in (0, 1, 25) do (
if /i !TextAlphabet!==!Alphabet[%%a]! (
set AlphabetNumber=%%a
!Alphabet[]! is an array containing alphabets
I tried echoing !TextAlphabet! and !Alphabet[%%a]! and when they are the same,
%AlphabetNumber% is still the value I set before the loop
I tried checking for white spacesin my variables but found none

import java.util.ArrayList;
import java.util.Iterator;
import java.util.StringTokenizer;
* @author BADRINARAYAN
public class stringTok {
public static void main(String[] ar)
    String st1 = "1,2,3,4,6,7,9,10,11";
    String st2 = "4,5,10,11";
    TreeSet<String> value=new TreeSet<String>();
    ArrayList<String> set1=new ArrayList<String>();
    ArrayList<String> set2=new ArrayList<String>();
    StringTokenizer s1=new StringTokenizer(st1,",");
    StringTokenizer s2=new StringTokenizer(st2,",");
    while(s1.hasMoreTokens())
        set1.add(s1.nextToken());
    while(s2.hasMoreTokens())
        set2.add(s2.nextToken());
    for(Iterator it1=set1.iterator();it1.hasNext();)
        String temp1=it1.next().toString();
        for(Iterator it2=set2.iterator();it2.hasNext();)
            if(temp1.equals(it2.next().toString()))
                value.add(temp1);
    System.out.println(value);
}Edited by: badri.m on Feb 15, 2010 3:25 AM

Similar Messages

  • How to compare two strings whether both are equal while ignoring the difference in special characters (example: & vs & and many others)?

    I attempted to compare two strings whether they are equal or not. They should return true if both are equal.
    One string is based on Taxonomy's Term (i.e. Term.Name) whereas other string is based on String object.
    The problem is that both strings which seem equal return false instead of true. Both string values have different special characters though their special characters are & and &
    Snapshot of different design & same symbols:
    Is it due to different culture or language?
    How to compare two strings whether both are equal while ignoring the difference in special characters (& vs &)?

    Hi Jerioon,
    If you have a list of possible ambiguous characters the job is going to be easy and if (& vs &) are the only charracters in concern awesome.
    You can use the below solution.
    Before comparing pass the variables through a replace function to standarize the char set.
    $Var = Replace($Var,"&","&")
    This is going to make sure you don't end up with ambiguous characters failing the comparison and all the char are "&" in this case.
    Similar technique is used to ignore Character Cases 'a' vs. 'A'
    Regards,
    Satyajit
    Please “Vote As Helpful”
    if you find my contribution useful or “Mark As Answer” if it does answer your question. That will encourage me - and others - to take time out to help you.

  • How to Compare two strings in PL/SQL

    Hi All,
    I need to compare two strings whether they are equal or not in PL/SQL.Is there any function to comparing the strings.

    Yes, the = sign.
    Are you after something like:
    IF v_string1 = v_string2 THEN
    ELSE
    END IF;?
    Edited by: Boneist on 27-Aug-2009 11:41

  • How to compare German strings with umlaut

    hi
    here is a solution for the problem to compare German strings containing umlaut, which I faced and where I did not find any solution yet!
    The right thing is to use the RuleBasedCollator class and define the additional rules (concerning the umlaut) by yourself and setting the strength of the rule interpretation to PRIMARY!
    Here is the code that works:
    public class UmlautTest { 
    public static void main (String args[]) {    
    String st1 = "Daettenb�ck";
    String st2 = "D�ttenbueck";
    String myRule = "< ae,�,AE,� < oe,�,OE,� < ss,�,SS < ue,�,UE,�";
    RuleBasedCollator myrbCol = null;
    try {
    myrbCol = new RuleBasedCollator(myRule);
    } catch (ParseException e) {
    e.printStackTrace();
    myrbCol.setStrength(Collator.PRIMARY);
    if (myrbCol.compare(st1, st2) != 0) {
    System.out.println("myrbCol: NICHT gleich!");
    } else {
    System.out.println("myrbCol: Gleich!");
    I hope that I could help anyone with that
    nocomm

    The � should be of course replaced by the missing umlaut!
    Sorry, but I didn't preview the topic!
    nocomm

  • How to compare a string with integer in jsp

    I have a field in database called as enddate
    i m trying to split the entire date and get date,month and year
    once i store the date in a variable called as fmdate which is string,
    i need to compare it with another integer.
    how can i compare it..heres my code
    stdate=RS.getString("start_date");
         fmdate=stdate.substring(8,10);
         fmmonth=stdate.substring(5,7);
         fmyear=stdate.substring(0,4);
    and this is where i want to compare the value of j to fmday...
    <td class="btext" valign="center">Day<select name="fmday">
    <%
    for(int j=1;j<=31;j++)
    String s;
    parseInt(s)=j;
    if (fmdate.equals(s))
    %>
    <option value="<%=j%>"><%=j%></option>
    <% } else { %>
    <option value="<%=j%>"><%=j%></option>
    <%
    } %>
    </select>
    pl help me...
    Thanks Srini

    j is an int, so you're just adding 0, not concatenating. Perhaps something like this would work.
    <%
      for(int j=1;j<=31;j++)
         String date = String.valueOf(j);
         if(j <= 9) {
            date = 0 + date;
         if (fmdate.equals(date)) {
    %>
      <option value="<%=date%>"><%=date%></option>
    <%
         } else {
    %>
      <option value="<%=date%>"><%=date%></option>
    <%
    %>Uhm, I assume there should be a 'selected' or something in one of the option tags?

  • How to compare 2 Strings that have different content in them..

    I have 2 Strings:
    String st1 = "1,2,3,4,6,7,9,10,11";
    String st2 = "4,5,10,11";
    I want to compare these 2 Strings where the result should be. Basically, any item from st2 is in st1: String res = "4,10,11";
    How can I do this in an efficient way?
    I was thinking of using StringTokenizer on st2 and compare each item to st1.... any help is appreciated. Thanks.

    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.StringTokenizer;
    * @author BADRINARAYAN
    public class stringTok {
    public static void main(String[] ar)
        String st1 = "1,2,3,4,6,7,9,10,11";
        String st2 = "4,5,10,11";
        TreeSet<String> value=new TreeSet<String>();
        ArrayList<String> set1=new ArrayList<String>();
        ArrayList<String> set2=new ArrayList<String>();
        StringTokenizer s1=new StringTokenizer(st1,",");
        StringTokenizer s2=new StringTokenizer(st2,",");
        while(s1.hasMoreTokens())
            set1.add(s1.nextToken());
        while(s2.hasMoreTokens())
            set2.add(s2.nextToken());
        for(Iterator it1=set1.iterator();it1.hasNext();)
            String temp1=it1.next().toString();
            for(Iterator it2=set2.iterator();it2.hasNext();)
                if(temp1.equals(it2.next().toString()))
                    value.add(temp1);
        System.out.println(value);
    }Edited by: badri.m on Feb 15, 2010 3:25 AM

  • How to compare 2 string value?

    i am creating a change password page, but having some problem,
    i use this
    if ( oldpassword == OrgPass)
    out.println("correct pass");
    else
    out.println("incorrect pass");
    both oldpassword and OrgPass are string, but even though the value of oldpassword and Orgpass are the same, it will still return a incorrect pass. Can anyone please help me with this?

    instead of this
    if ( oldpassword == OrgPass)
    out.println("correct pass");
    try this
    if ( oldpassword.equals(OrgPass))
    out.println("correct pass");

  • How to compare two strings with each other?

    Hello,
    I have modeled a formular which has a radio group and a button. Furthermore, I have one result state corresponding to each option in the radio group.
    In order to determine which result state actually is to be reached I want to attach a condition to each flow to the result states that tests which option has been chosen.
    Which operator can I use for writing these conditions? I have tried the "like" operator as well as the "==" operator but neither seems to work.
    I have written something like:
    =LIKE(@decision, 'option a')
    as well as:
    =(@decision=='option a')
    What am I doing wrong here?
    Thank you very much
    Alexander

    Hi Alexander,
    Could this be an Upper/Lower case issue.
    I tried the following expression
    =(@TXT1=="opt a")
    and it worked.
    If you want your expression to ignore case you should use this expression:
    =(UPPER(@TXT1)==UPPER("opt a"))
    In case you're not sure what is the exact string in the field (@decision) you can always use the PROMPT action to display the field's value.
    Regards,
    Udi

  • Comparing 2 strings in if statement

    Hi All,
    I want to compare two strings in if statement. When I use "==" then its throwing error that expected number and got string. Can anyone please let me know how can we compare two strings in an IF statement?
    Thanks in advance

    The OP doesn't state what release he's on.
    The functions @LIKE and @MBRCOMPARE are 11.1.2 and up only.
    OP, if you're at a lower release, I've faced this problem as well in 11.1.1.3. Here's an older thread that detailed how I got around it for a client:
    Re: How to compare two strings in calc script?
    It really wasn't hard to do and the performance, in the limited context I was using it in, was fine.
    Regards,
    Cameron Lackpour

  • How to Compare Two Strng without .equals() method

    Hiii,
    How to compare two Strings with out .equals method if there are white spaces in between these string it should be avoided..
    eg: ab cd ef g is equal to a bc de fg
    Please give me the logic or code..
    Your help will be appreciated

    dude find the code without the equal method
    public class test {     
         public static void main(String args[])
              String str = "ab cd ef g" ;
              String str1 = "a bc de fg";
              char []ch = str.toCharArray();
              char []ch1 = str1.toCharArray();
              int counter =0, counter1 = 0;
              while(counter < ch.length && counter1 < ch1.length)
                   while(ch[counter]==' ')
                        counter++;
                   while(ch1[counter1]==' ')
                        counter1++;
                   if(ch[counter] != ch1[counter1])
                        break;
                   counter++; counter1++;
              if(counter == ch.length && counter1 == ch1.length)
                   System.out.println("true");
              else
                   System.out.println("false");
    }

  • URGENT! I need to compare a String with a line in a .txt file

    I'm a college student and I have a very simple question i guess. I need to write an if procedure which compares if a line of a .txt file is equal to something, but I just don't know how to do it. HELP!

    What specifically are you asking for? How to compare two strings?
    String s = "cat";
    String t = "Cat";
    if (s.equals(t))
       System.out.println('They are equal');    // does not print out
    if (s.equalsIgnoreCase(t))
       System.out.println('They are equal');    // prints out

  • Compare 2 string within DECODE

    Hi All,
    Is there anyone else able to guide me on how to compare 2 strings inside DECODE function? Currently I need to check whether string1 = string2.
    I need a DECODE function which has similar function like below,
    eg: IF(string1 = String2? 1, 2) => java code

    DECODE(string1,string2,1,2)If string1=string2 then 1 will be returned else 2 will be returned.

  • How to read a string from file & assign the val to a variable in batch file

    Hi,
    How to read a string from a file and assign the value to a variable then return the value to the screen in windows batch file?
    Any suggestions?
    thanks.

    Unless this is a homework question then I don't see the purpose of doing this, but....
    You should be looking a the supplied package utl_file to get the string out of the file, dbms_output to display the string and then google windows batch/command files calling sqlplus to execute your program.
    Andre

  • How to compare Date/time string

    I read from datalog file including Date/time string ,and want to query the special Date/time string span ,how to compare the data/time string ?

    Hello Joshua,
    To compare date/time you have to extract the different components (day, month, year, hour, minute, second) anyway. Why not "convert to seconds"? I think it's easier to compare one number (where you also can do other math, like calc the difference and so on) than to compare seven (?) parameters with some exceptions... If the dates are read from excel (there was a similar thread some days ago), why not convert to seconds in excel (just a format change)?
    Best regards,
    GerdW
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • How can u get the matching percentage whenever compare the pdf files(compare the strings)

    Actually I want matching percentage whenever compare the pdf files.First I had completed 
    read the pdf files content into string
    my code like as
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.IO;
    using iTextSharp.text;
    using iTextSharp.text.pdf;
    using iTextSharp.text.pdf.parser;
    namespace WindowsFormsApplication1
    public partial class Form1 : Form
    string str1;
    string filename;
    string path;
    string str2;
    public Form1()
    InitializeComponent();
    private void button1_Click(object sender, EventArgs e)
    OpenFileDialog openFileDialog = new OpenFileDialog();
    openFileDialog.CheckFileExists = true;
    openFileDialog.AddExtension = true;
    openFileDialog.Filter = "PDF files (*.pdf)|*.pdf";
    DialogResult result = openFileDialog.ShowDialog();
    if (result == DialogResult.OK)
    filename = Path.GetFileName(openFileDialog.FileName);
    path = Path.GetDirectoryName(openFileDialog.FileName);
    textBox1.Text = path + "\\" + filename;
    private void button2_Click(object sender, EventArgs e)
    OpenFileDialog openFileDialog = new OpenFileDialog();
    openFileDialog.CheckFileExists = true;
    openFileDialog.AddExtension = true;
    openFileDialog.Filter = "PDF files (*.pdf)|*.pdf";
    DialogResult result = openFileDialog.ShowDialog();
    if (result == DialogResult.OK)
    filename = Path.GetFileName(openFileDialog.FileName);
    path = Path.GetDirectoryName(openFileDialog.FileName);
    textBox2.Text = path + "\\" + filename;
    public static string ExtractTextFromPdf(string filename)
    using (PdfReader r = new PdfReader(filename))
    StringBuilder text = new StringBuilder();
    for (int i = 1; i <= r.NumberOfPages; i++)
    text.Append(PdfTextExtractor.GetTextFromPage(r, i));
    string result = text.ToString();
    return result;
    public static string Extract(string filename)
    using (PdfReader r = new PdfReader(filename))
    StringBuilder text = new StringBuilder();
    for (int i = 1; i <= r.NumberOfPages; i++)
    text.Append(PdfTextExtractor.GetTextFromPage(r, i));
    string result1 = text.ToString();
    return result1;
    private void button3_Click(object sender, EventArgs e)
    str1 = Form1.ExtractTextFromPdf(textBox1.Text);
    str2 = Form1.Extract(textBox2.Text);
    }Finally how can u get the matching percentage whenever compare the pdf files(compare the strings)please help me.thank u

    Hi,
    Based on your code, I see your code related to
    iTextSharp Pdf.
    iText is a third party library to create PDF originally written for java. iTextSharp is
    the C# adaptation of that library.
    Question regarding iText are better asked on the iText forum, rather than the Microsoft Forum:
    http://itextpdf.com/support
    Thanks for your understanding.
    Best regards,
    Kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

Maybe you are looking for