check if a substring exists in a string

check if a substring exists in a string

Please I jave an arraylist composed as follwoing [w1, w2, w3, w4, w1.w2.w3, w2.w3.w4, w3.w4, w2.w4, w1.w3, w1.w2]

w2.w4 is a subset of w2.w3.w4 ?how I recognize it

also

w1.w3 is a subset of w1.w2.w3 ?how I recognize it

same for w1.w2 in w1.w2.w3.

I nedd your help.

Thanks a lot

View Answers

June 11, 2012 at 8:17 PM

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
public class SubString {
public static void main(String args[]) throws IOException{
    ArrayList<String> list=new ArrayList<String>();
    try{
        FileReader fread=new FileReader("meta.txt");
        BufferedReader br=new BufferedReader(fread);
        String strLine;
        while((strLine=br.readLine())!=null){
            list.add(strLine);
        }
        System.out.println("enter the string");
    Scanner sc=new Scanner(System.in);
    String substring=sc.nextLine();
String sub=substring.substring(0,2);

    for(String s:list){
        if(s.substring(0, 2).equalsIgnoreCase(sub)){
            System.out.println(substring+" "+"is having subset and is subset of the following strings"+s.toString());
        }
    }
}
    catch(Exception e){
        System.out.println(e);
    }
}
}

i don't think i have achieved it completely but i have done some thing almost related to this topic


June 11, 2012 at 8:21 PM

import java.io.BufferedReader; 
import java.io.FileReader; 
import java.io.IOException; 
import java.util.ArrayList; 
import java.util.Scanner; 
public class SubString { 
public static void main(String args[]) throws IOException{ 
    ArrayList<String> list=new ArrayList<String>(); 
    try{ 
        FileReader fread=new FileReader("C:\\Documents and Settings\\venkatanaveen.jc\\Desktop\\meta.txt"); 
        BufferedReader br=new BufferedReader(fread); 
        String strLine; 
        while((strLine=br.readLine())!=null){ 
            list.add(strLine); 
        } 
        System.out.println("enter the string"); 
    Scanner sc=new Scanner(System.in); 
    String substring=sc.nextLine(); 
String sub=substring.substring(0,2); 

    for(String s:list){ 
if(s.substring(0, 2).equalsIgnoreCase(sub)){ 
System.out.println(substring+" "+"is having subset and is subset of the following strings"+s.toString()); 
        } 
    } 
} 
    catch(Exception e){ 
        System.out.println(e); 
    } 
} 
} 
i don't think i have achieved it completely but i have done some thing almost related to this topic

June 11, 2012 at 8:25 PM

i included all values into a .txt file and added to arraylist









Related Tutorials/Questions & Answers:
check if a substring exists in a string
check if a substring exists in a string  Please I jave an arraylist composed as follwoing [w1, w2, w3, w4, w1.w2.w3, w2.w3.w4, w3.w4, w2.w4, w1.w3, w1.w2] w2.w4 is a subset of w2.w3.w4 ?how I recognize it also ADS
How to check if a string contains a substring in iOS?
clicks on the 'Check If Exists' button application will find the string and show...Function for checking the presence of a substring in a string (NSString... the presence of substring in a string (NSString) and there is no readymade function
Advertisements
How to check if a string exists in a string in JavaScript?
How to check if a string exists in a string in JavaScript
string and substring
string and substring  bbbnnnmmm*ccc remove second asterick and display it as bbb*nnnADS_TO_REPLACE_1 mmm*ccc
string and substring
string and substring  my code is bbbnnnmmm*ccc how to remove the asterick at second position and display the code as bbb*nnn mmm*ccc
protractor check if element exists
to check if element exists in protractor framework? Thanks   Hi, There are methods protractor to check if element exists. You can use the following...protractor check if element exists  Hi, We are working
Search string using substring
Search string using substring  I want to print a string by searching a substring of that string. - i want to print email-ids from word files (resumes...*; class FileRead { public static void main(String[] args) { String
remove a substring from a string
remove a substring from a string  Please I jave an arraylist composed as follwoing [w1, w2, w3, w4, w1.w2.w3, w2.w3.w4, w3.w4, w2.w4, w1.w3, w1.w2] w2.w4 is a subset of w2.w3.w4 ?how I recognize it also ADS_TO_REPLACE_1 w1.w3
How to check whether database exists?
How to check whether database exists?  Hi, I have to create... to creating the database, i want to check whether database exists or not? How can i do this check. can any one help me on this. Please find thesample codeADS
Check the File Exists in PHP Program
Check the File Exists in PHP Program  Hi, I trying to create a application to find or retrieve the existing files. So, Please help me or suggest any online reference that explain about the file exists function in PHP? Thanks
String substring method example
.style1 { font-size: medium; } String substring() method example... a string. String class provide methods for finding substring from string. Method...;; var substring:String = str.substring(5,13);ADS_TO_REPLACE_4
C String Substring
C String Substring       In this section, you will learn how to get the substring from a string in C. You can see in the given example, a string and a method substring
JSP check email exists or not
JSP check email exists or not In this tutorial, you will learn how to check from the database whether entered email-id exists or not. The given code accepts the email id from the user and check whether the given email id already
String substring(int beginIndex)
String substring(int beginIndex)   ... the substring(int beginIndex) method of String class. We are going to use substring(int beginIndex) method of String class in Java. The description of the code
How to check a file exists or not in java.
Description: This example demonstrate how to check a file exits at a given path or not.  The method isFile() of the File class check for its existence...(String[] a) {     File findFile = 
Check if parameter exists in servlet request
Check if parameter exists in servlet request... will see how to check is parameter exists in servlet request. In this example.... getParametersNames() : This method returns an Enumeration of String objects . We can use two
Check Whether Record is already Exists or Not with Database Connectivity - Java Beginners
Check Whether Record is already Exists or Not with Database Connectivity  Hello Sir I want Program to Check Whether ID is Already exists in the database with Swing Application ,if It is Already Exists then I want To Show MsgBox
String substring(int beginIndex, int endIndex)
String substring(int beginIndex, int endIndex)  ... explanation about the substring(int beginIndex, int endIndex) method of String class. We are going to use substring(int beginIndex, int endIndex) method of String
Video Tutorial: How to check if a folder exists in Java through a source code
How to check if a folder exists in Java through a source code Java is an all... facilities. Here is the video tutorial of "How to check if a folder exists in Java... through which we can check if a folder exists or not in Java. A new Java
Java Substring
of String is called substring. Substrings are also a String. Substring is used... this method to find out the substring from a given String. substring() methodADS... is String which is a substring of the current String. This method is written
C Programming SubString Program
C Programming SubString Program  Sir I want to Check whether the Single Substring is present in the given 3 string. characters. eg if i entered... entered to check PROGRAM is exists in given three strings then output
write a java program for inserting a substring in to the given main string from a given position
write a java program for inserting a substring in to the given main string from a given position  write a java program for inserting a substring in to the given main string from a given position
How to substring in Java?
"; String substring = string.substring(3); Check more example at Taking...How to substring in Java?  Hi, I want to get a part of String... the substring() method of Java for getting a part of string based on the index number
C get Substring from String
C get Substring from String       This section illustrates you how to get the substring using... In the given code, we have consider will as str2 and the whole string as str1
How to check if a string exits in a string script in Java script?
computer science. Here is the video tutorial of "How to check if a string exists... will be taught how to write a function in java script to check if a string exists... then the content is not found. Thus, we can check if a string exists in a string in java
SubString in Java
SubString(), a method of String class is used to get a part of original string... then it will return empty String. Example of SubString in Java: import java.io.... on the console System.out.println(strLine); String subString = str.substring(0
PHP File Manipulation File existance checking Tutorial, PHP check file exists
File existence checking If you want to check whether a file exists, you should use file exists PHP function. Syntax: file_exists($path), where...=/images/file1.jpg; file_exists($DOCUMENT_ROOT.$TmpName); where $DOCUMENT_ROOT - PHP
JPA Substring() Function
() function. The substring() function returns the some part of string arguments..., second is starting index and third is length of string . JPA Substring... JPA Substring() Function   
Substring in java
Substring in java   example:output 0f the code.. Input String:University of the Cordilleras Input Substring:of Output:1 ...use non static methods,don't use (.Substring).. ..please help me.. ..thank you.. deadline:November
Substring in java
Substring in java   example:output 0f the code.. Input String:University of the Cordilleras Input Substring:of Output:1 ...use non static methods,don't use (.Substring).. ..please help me.. ..thank you.. deadline:November
find and substring
String"); String findstring = keybord.readLine(); String substring = keybord.readLine(); findreplace(findstring,substring); } catch(IOException io...find and substring   **import java.io.BufferedReader; import
help with substring in c programing
. Please help with substring function,prompt the user for two strings and display whether or not the second string is a substring of the first string. Regards...help with substring in c programing  Hi I could not found programming
Use of <fn:subString(String, int, int)> Tag of JSTL
Use of <fn:subString(String, int, int)> Tag of JSTL...="${fn:substring(string,start,end)}"/> </font>... of a string of specified length. This takes string and integer type as arguments
Check for any elements exists between the current position and the limit of a buffer.
Check for any elements exists between the current position and the limit of a buffer. In this tutorial you will see how to check for existence of any... method returns true when there exists atleast one element in the buffer
SubString help - Java Beginners
System.out.println(strLine); String subString = str.substring(0); System.out.println("String after index: " + subString); subString...SubString help  Hi , I would appreciate if somebody could help me
String indexOf method example
of the substring from the string. The indexOf() method start to search from beginning of the string and matching the substring from substring, if substring... .style1 { font-size: medium; } String indexOf() method example
Check for number of elements exists between the current position and the limit of a buffer.
Check for number of elements exists between the current position and the limit of a buffer. In this tutorial you will see how to check for existence of any...;CharBufferDemo {   public static void main(String[] 
check
check  interface validateInfo { public void validate(String empcode, String password); } class updateInfo implements validateInfo { String empcode; String password; public void validate(String
Java Check Permutations of String
Java Check Permutations of String In this tutorial, you will learn how to check whether two strings are permutations of each other. You are all aware...*; class CheckPermutation{ public static boolean isPermutation(String st1
JavaScript substring length
JavaScript substring length...; This section illustrates you how to determine the length of substring in JavaScript. You can see in the given example, we have defined a string and used the JavaScript
JavaScript indexOf substring
the parameters substring is the specified string and 0 is the index... JavaScript indexOf substring...; In this section, we are going to find the location of substring using
Java SubString
; String class provides number of methods for manipulating the strings. substring... of the original string as String object. substring provides a way of making a copy of a piece of a String. This method has two forms: substring(int beginIndex): 
How to substring in JQuery?
How to substring in JQuery?  Hi, I my JQuery application I am getting the value from server using Ajax. I have to substring the value in jQuery.... Please let's know How to substring in JQuery? Thanks   Hi
Taking Substring
string. You will learn how to use the substring() method of String class... are creating a new sub string with the help of substring() function of String class...): This method is used to find all sub string after index i. substring
Java delete file if exists
Java delete file if exists  Hi, Hi how to delete file if exists? I need example code of java delete file if exists. Thanks   Hi, following code can be used: String tempFile = "C:/mydir/myfile.txt"; //Delete
String slice method example
:- The string slice() and substring() methods functionality is same but difference... is negative that means slice() find substring end of the string...); // second type var substring:String = str.slice(-5,13);ADS_TO_REPLACE_5
ModuleNotFoundError: No module named 'substring'
ModuleNotFoundError: No module named 'substring'  Hi, My Python... 'substring' How to remove the ModuleNotFoundError: No module named 'substring' error? Thanks   Hi, In your python environment you
Check for any elements exists between the current position and the limit of a double type buffer.
Check for any elements exists between the current position and the limit of a double type buffer. In this tutorial you will see how to check for existence.... The hasRemaining method returns true when there exists at least one element
find a substring by using I/O package
find a substring by using I/O package  Write a java program to find a sub string from given string by using I/O package
file_exists php not working
file_exists php not working  file_exists php not working. Please give me the simple example

Ads