Compare two strings and verify they have same alphabets

If i have two strings....s and t. I want to return whether s contains every letter in t. For example, "abcd" contains all the letters in "bbdc", since every letter in the second string appears in teh first.
thanx

If i have two strings....s and t. I want to return
whether s contains every letter in t. For example,
"abcd" contains all the letters in "bbdc", since every
letter in the second string appears in teh first.This will do the job in s.length()*t.length() steps.
//  Indicates whether s contains every letter in t.
boolean allCharsContainedIn(String s, String t) {
    int len = t.length();
    for (int i = 0; i < len; i++) {
        if (s.indexOf(t.charAt(i) == -1)
            return false;
    return true;
}S&oslash;ren

Similar Messages

  • Compare two strings and the save the greater

    To devolop a vi,it can compare two strings.A string is gived,the other is saved previously.If greater,then save,or do nothing.

    Hi,
    I am assuming by "greater" you mean the string length.
    Use the string length function from the strings palette, with shift-registers on a while loop. Write to the shift-register the "greater" string.
    I am attaching a diagram screenshot for this. NOTE: depending on how you want this VI to run, you can move the input and output string control and indicator inside our outside the while loop.
    Hope this is what you were looking for.
    Khalid
    Attachments:
    strlen.gif ‏17 KB

  • 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.

  • An error ocurred while loading this content! Ive using my ATV for more than 6 months and last week i update the sw and since then i have rented two movies and keep seeing the same message. I have reset the ATV two times without success. Any suggestions?

    I keep getting this message: AN ERROR OCURRED WHILE LOADING THIS CONTENT
    ATV was working fine until i did a version update last week. Since then i have rented two movies and keep getting the same message
    I restarted the ATV - no success
    I reset my wireless - no success
    I reset my ATV - no success
    netflix is working fine since i was able to see a movie there. Youtube was also working fine. I think there should be something wrong with iTunes
    Any ideas?

    I keep getting this message: AN ERROR OCURRED WHILE LOADING THIS CONTENT
    ATV was working fine until i did a version update last week. Since then i have rented two movies and keep getting the same message
    I restarted the ATV - no success
    I reset my wireless - no success
    I reset my ATV - no success
    netflix is working fine since i was able to see a movie there. Youtube was also working fine. I think there should be something wrong with iTunes
    Any ideas?

  • I have two iPhones and synchronize with the same macbook. How I do segregate both applications and data?

    I have two iPhones and synchronize with the same macbook.  How do I segregate both applications and all the data?

    Hi Jamesdwills,
    Welcome to the Support Communities!
    If you are using the same Apple ID on both devices, the Game Center profile should be the same.
    Check out this information from the iPad User Guide.  Try signing out of the Game Center on both devices and then sign back in with the correct Apple ID:
    Using Game Center
    http://support.apple.com/kb/ht4314
    Game Center settings - iPad User Guide
    http://help.apple.com/ipad/7/#/iPad9a13d039
    Game Center settings
    Go to Settings > Game Center, where you can:
    Sign out (tap your Apple ID)
    Allow invites
    Let nearby players find you
    Edit your Game Center profile (tap your nickname)
    Get friend recommendations from Contacts or Facebook
    Specify which notifications you want for Game Center. Go to Settings > Notifications > Game Center. If Game Center doesn’t appear, turn on Notifications.
    Change restrictions for Game Center. Go to Settings > General > Restrictions.
    Cheers,
    - Judy

  • Compare two strings in a formula

    Hi,
    I'd like to know if there's a way to compare two strings in a formula ?
    I have this consition:
    IF(@SUBSTRING(@NAME(@CURRMBR(TIME_FROM)),5)==@NAME(@CURRMBR(TIME)))
    But the == operator can only compare two data.
    Thanks,
    Cyril

    Hi,
    thank you both for your answers.
    When I figured that the == operator was for data only, I didn't even try to compare member names.
    I finally used the solution that Cameron suggested in another conversation. I created a date measure, and loaded some data since the beginning of my time to the end.
    It starts in 1974 (annually), then becomes monthly data, and then daily data from 2009, so it's not so many blocks to br created. In the end I have the same value for "from 2008"/"from Apr 30", and I can easily compare my dates.
    Note that I could have also used the @TODATE function, which turns a date into a number, but the format of date is limited and doesn't fit the format of my member names, so I got lasy... and I'm not sure my users would have apreciated that ;)
    Thanks, this post is solved.
    Cyril

  • Cannot refresh table - test connection works fine but refresh gives "We couldn't refresh the connection. Please go to existing connections and verify they connect to the file or server." error.

    I'm having some difficulty updating a table in my powerpivot data model. The data for the table is stored in a local excel file; if I go to
    Existing Connections select the connection and do a test then everything is successful. When however I try to refresh that particular table I get the following error:
    "We couldn’t refresh the connection. Please go to existing connections and verify they connect to the file or server."
    In the past I had this and it was an authentication issue, the files are stored on SharePoint and I wasn't logged in to Sharepoint - I have however checked this and it can't be the issue because I have other tables linked to other excel files in the same
    location that are refreshing without issue. Can anyone think of what may be causing it?
    I have even tried creating a new local excel with the same data, added it to the data model and then tried a refresh and I I get exactly the same issue. 
    Are there any known issues with refreshing data from an Excel file if, after the initial import, you add columns to the table in the excel file I was wondering if this might contribute?
    Thanks

    Hi Maracles,
    Thanks for your post.
    From your description, I tried to reproduce this issue on my test environment. However, everything is fine for me. Could you please post the specific version of SQL Server PowerPivot for Excel?
    You can try to use a trace file to troubleshoot errors in PowerPivot. If this issue still persists, please try to reinstall SQL Server PowerPivot for Excel to see if this helps.
    For more information, please see:
    PowerPivot Options & Diagnostics Dialog Box:
    http://technet.microsoft.com/en-us/library/gg399091.aspx
    Using a Trace File to Troubleshoot Errors in PowerPivot:
    http://www.sqlchick.com/entries/tag/powerpivot
    Best Regards,  
    Elvis Long
    TechNet Community Support

  • Compare two strings for partial or full match

    I have been trying to figure out away of comparing two strings.
    I can get the full string matching to successfully work but am struggling on how to get partial eg wildcard search working.
    say I had names like paul Duncan, George Morrison.
    I have split them up so its now paul , duncan i then use the users entered string to compare it against the name name to see if it matches anything in the first name or the last name if it does i added it to an arraylist.
    however i have tried t use a indexof as i believe this looks for similarity (Substring matches?) but it always returns -1.
    Could anyone possibly direct me to a method that will allow me to use partial text string to match it against stored user names.
    eg user enters pa
    I would return anything that would contain pa
    thanks for any help

    thank you for the reply
    Sorry I forgot to put in the code.
    This is a reduced down version including the read in from a text file as well as the index of if statement and the adding of it to an array list.
    public class FindContact {
    String res;
    /** Creates a new instance of FindContact */
    public FindContact() {
    public Object[] FindAUser(String passSearch) {
    System.out.println("getting here");
    ArrayList found = new ArrayList();
    String patternStr = ",";
    int j, i = 0;
    try {
    BufferedReader in = new BufferedReader(new FileReader("H:\\out.txt"));
    String str;
    while ((str = in.readLine()) != null) {
    String[] fields = str.split(patternStr);
    //for(j=0;j < fields.length;j++) {
    if (fields.length != 0) {
    if (passSearch.indexOf(fields[0])!=-1 || passSearch.indexOf(fields[1])!=-1) {
    found.add(str);
    System.out.println("ENDDDDDDDD value ");
    in.close();
    } catch (IOException e) {
    System.out.println(e.toString());
    Object[] foundResult = new Object[found.size()];
    foundResult = found.toArray();
    if (foundResult.length >= 0) {
    System.out.println(foundResult.length);
    return foundResult;
    Hope that helps as it has confused me and am not sure why it is not returning a value.
    Should I maybe use the contain method instead to search for the user inputted string?

  • Having a problem with dates when I send my numbers doc to excel. dates are all out and that they have to cut and paste individual entries onto their spreadsheet. Any idea how I can prevent this

    having a problem with dates when I send my numbers doc to excel. dates are all out and that they have to cut and paste individual entries onto their spreadsheet. Any idea how I can prevent this.
    I'm using Lion on an MBP and Numbers is the latest version

    May you give more details about what is wrong with your dates ?
    M…oSoft products aren't allowed on my machines but I use LibreOffice which is a clone of Office.
    When I export from Numbers to Excel and open the result with LibreOffice, the dates are correctly treated.
    To be precise, dates after 01/01/1904 are correctly treated. dates before 01/01/1904 are exported as strings but, as it's flagged during the export process, it's not surprising.
    Yvan KOENIG (VALLAURIS, France) mardi 3 janvier 2012
    iMac 21”5, i7, 2.8 GHz, 12 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.2
    My iDisk is : http://public.me.com/koenigyvan
    Please : Search for questions similar to your own before submitting them to the community
    For iWork's applications dedicated to iOS, go to :
    https://discussions.apple.com/community/app_store/iwork_for_ios

  • 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

  • TS2972 used to be able to pick out which songs in iTunes in my computer were not on a 2nd computer on homeshare in iTunes 10.  Now with V11, cant find the button that compares two libraries and finds the songs that are different.  Anyone know how to do th

    Used to be able to pick out which songs in iTunes in my computer were not on a 2nd computer on homeshare in iTunes 10.  Now with V11, cant find the button that compares two libraries and finds the songs that are different.  Anyone know how to do this now?

    Jneklason wrote:
    ~snip~
    I know this email is confusing and really hard to understand...perhaps now you will know how i've been feeling--lost and confused with all the mis-information, with a hit and miss phone, and out of time with all the 1 1/2 hr to 2 hrs EACH wasted on this issue.
    On top of all this, I can't even find out how to file a complaint with anyone higher up than Customer Service.
    I hate to tell you this, but you didn't write an email. You wrote a discussion post on the Verizon Wireless Community forum which is a public peer to peer forum. Unfortunately since you didn't mark your post as a question, the VZW reps that roam this community won't ever see your post. Before you re-post it, don't. Duplicate posts get removed from the community.
    I see there were several missteps both by the reps and yourself in your post. First you should have insisted on returning the phone within the 14 day return policy period. Second which Samsung Galaxy mini model did you purchase? The S3 mini or the S4 mini? Did you do any research prior to deciding on this device. The reps at that time deflected the easiest course of action, by trying to get you to replace the phone under insurance instead of returning the phone. The Early Edge payment option requires the current phone on the line using the early Edge must be returned to Verizon Wireless. Did you once considered going to a third party site like Swappa to purchase a gently used device for your daughter?

  • I have an iPhone 4S and an iPad2, can i use both chargers in the iPhone and iPad, they have different amperage...

    I have an iPhone 4S and an iPad2, can i use both chargers in the iPhone and iPad, they have different amperage...

    You can use your iPad charger to charge your iPhone 4S. Not recommended to use your iPhone charger to charge your iPad. So, use your iPad charger to charge both.

  • Compare two string in different line in textarea

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class TextCounterPanel extends JPanel {
    private JTextArea textInput;
    private JLabel lineCountLabel;
                        public TextCounterPanel() {
                        setBackground(Color.DARK_GRAY);
                        textInput = new JTextArea();
                        textInput.setBackground(Color.WHITE);
                        JPanel south = new JPanel();
                        south.setBackground(Color.DARK_GRAY);
                        south.setLayout( new GridLayout(4,1,2,2) );
                             JButton countButton = new JButton("Process the Text");
                             countButton.addActionListener( new ActionListener() {
                                  public void actionPerformed(ActionEvent evt) {
                                       processInput();
                             south.add(countButton);
                        lineCountLabel = new JLabel(" Number of lines:");
                        lineCountLabel.setBackground(Color.WHITE);
                        lineCountLabel.setForeground(Color.BLUE);
                        lineCountLabel.setOpaque(true);
                        south.add(lineCountLabel);
                        setLayout( new BorderLayout(2,2) );
                        setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
                        JScrollPane scroller = new JScrollPane( textInput );
                        add(scroller, BorderLayout.CENTER);
                        add(south, BorderLayout.SOUTH);
    public void processInput() {
    String text,vin; // The user's input from the text area.
    text = textInput.getText();
    vin =text.substring(25,42);
    lineCountLabel.setText(" vin: " + vin);
    } // end class TextCounterPanel
    How can I compare two string in different line in text area

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class TextCounterPanel extends JPanel {
    private JTextArea textInput;
    private JLabel lineCountLabel;
    public TextCounterPanel() {
    setBackground(Color.DARK_GRAY);
    textInput = new JTextArea();
    textInput.setBackground(Color.WHITE);
    JPanel south = new JPanel();
    south.setBackground(Color.DARK_GRAY);
    south.setLayout( new GridLayout(4,1,2,2) );
    JButton countButton = new JButton("Process the Text");
    countButton.addActionListener( new ActionListener() {
    public void actionPerformed(ActionEvent evt) {
    processInput();
    south.add(countButton);
    lineCountLabel = new JLabel(" Number of lines:");
    lineCountLabel.setBackground(Color.WHITE);
    lineCountLabel.setForeground(Color.BLUE);
    lineCountLabel.setOpaque(true);
    south.add(lineCountLabel);
    setLayout( new BorderLayout(2,2) );
    setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
    JScrollPane scroller = new JScrollPane( textInput );
    add(scroller, BorderLayout.CENTER);
    add(south, BorderLayout.SOUTH);
    public void processInput() {
    String text,vin; // The user's input from the text area.
    text = textInput.getText();
    vin =text.substring(25,42);
    lineCountLabel.setText(" vin: " + vin);
    } // end class TextCounterPanel

  • Compare two tables and log the difference

    Hi,
    I want to compare two tables and log the difference in new table with the fields as (old value,new value, column name). The column name should be the changes value column

    Can you show an example?
    SELECT Foo.*, Bar.*
       FROM Foo
            FULL OUTER JOIN
            Bar
            ON Foo.c1 = Bar.c1
               AND Foo.c2 = Bar.c2
               AND Foo.cn = Bar.cn
     WHERE Foo.key IS NULL 
        OR Bar.key IS NULL; 
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Bought 5 ringtones for my phone...they were working this morning and now they have disappeared off my iPhone

    I just recently got my iPhone. Bought 5 ringtones for the my phone. They worked perfectly until this afternoon and now they have disappeared. Where do I look for them...they are not in "purchased" section

    Settings > Sound > Ringtone > under Ringtones

Maybe you are looking for

  • Why can I load Image from jar?

    hi,all: I've packed all gif images into a jar file,it works well on jdk1.4.2_05 with this command: java -jar pos.jar but failed on other jdk versions lower than jdk1.4.2_05. here is the package structure: ├─resource │ ├─configfile │ └─images here is

  • Loading .txt file in the Database

    I want to load .txt file in a table with datatype as LONG. Please Specify how i do i upload it using SQL Loader or any other Utility. Detail step would be a great help as this very urgent. Thanks Mona

  • Not able to reply questions -- still not able to reply

    dear team,             still i am not able to reply kindly help

  • Problem with LOGIC AUDIO 5 (BIG BOX) any Help is Useful

    Hi, I just sold my old Logic 5 Audio (big Box) on Ebay, but the new owner claims that he can't install the software without a serial(In my opinnion he should be able to install when he has the XSKey). Where can I ask for the serial, because I don't h

  • Form settings transfer to multiple users

    Hello, I know that this question has been asked before in the forum. But I could not find any definite answer to it. Can the form and other UDF settings be transferred to multiple users automatically? Or do I need to manually make those settings for