Results 1 to 3 of 3
  1. #1
    sidharth is offline Member
    Join Date
    Nov 2009
    Posts
    8
    Rep Power
    0

    Default java regular expression to search block/string/word exist in a paragraph?

    Hi ,

    i am new to java regular expression.

    Consider the follwoing paragraph :

    The Internet is a global system of interconnected computer networks that use the standardized Internet Protocol Suite (TCP/IP) to serve billions of users worldwide. It is a network of networks that consists of millions of private and public, academic, business, and government networks of local to global scope that are linked by copper wires, fiber-optic cables, wireless connections, and other technologies. The Internet carries a vast array of information resources and services, most notably the inter-linked hypertext documents of the World Wide Web (WWW) and the infrastructure to support electronic mail. In addition it supports popular services such as online chat, file transfer and file sharing, gaming, commerce, social networking, publishing, video on demand, and teleconferencing and telecommunications. Voice over Internet Protocol (VoIP) applications allow person-to-person communication via voice and video.

    The origins of the Internet reach back to the 1960s when the United States funded research projects of its military agencies to build robust, fault-tolerant and distributed computer networks. This research and a period of civilian funding of a new U.S. backbone by the National Science Foundation spawned worldwide participation in the development of new networking technologies and led to the commercialization of an international network in the mid 1990s, and resulted in the following popularization of countless applications in virtually every aspect of modern human life. As of 2009, an estimated quarter of Earth's population uses the services of the Internet.

    I need to do the following :

    1. To search a given block of text exist
    For example :
    Search the follwing block exist

    ", and other technologies. The Internet carries a vast array of information resources and services, most notably the inter-linked hypertext documents of the World Wide Web (WWW) and the infrastructure to support electronic mail. In addition it supports popular services such as online chat, "

    2. To search a string or block of text exist

    For example :

    Search the string
    "World Wide Web (WWW) and the infrastructure to support electronic mail. "
    OR search the block of text in above (point 1).
    3.Search if the given block of text or string doesn't exist :

    For example :
    Follwoing string shouldn't exist :
    Voice over Internet Protocol (VoIP) applications allow person-to-person communication via
    4.Search a given word exist or shouldn't exist .

    Please help me to resolve the above regular expression.

  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    6

    Default

    This doesn't really sound like a regular expressions problem, more of a "does a given string contain, or not contain a specific substring"

    For example,
    Java Code:
    String allTheText = "The Internet is a global system...."; // that paragraph you had
    
    // for #1
    String findText = ", and other technologies. ...";  // that block of text you want to find
    
    boolean blockExits = allTheText.indexOf(findText) >= 0;

  3. #3
    sidharth is offline Member
    Join Date
    Nov 2009
    Posts
    8
    Rep Power
    0

    Default

    i agree with you .But indexOf(String) will search for a exact pattern ..here i may give the string with spaces or with quotes .. how to achieve this kind of operations ..i need a common API for which i pass my block and the paragraph .Finally the API should return which contains the specified block or not ..(the block may be set of words , a word ...)

    please help me ..

Similar Threads

  1. Java Regular expression ?
    By sidharth in forum Advanced Java
    Replies: 12
    Last Post: 11-14-2009, 12:09 PM
  2. Java Regular Expression help
    By royalibrahim in forum Advanced Java
    Replies: 11
    Last Post: 11-12-2009, 02:27 AM
  3. Validating url with regular expression??
    By kirtichopra2003 in forum Advanced Java
    Replies: 2
    Last Post: 10-07-2009, 02:29 PM
  4. regular expression
    By ras_pari in forum Advanced Java
    Replies: 27
    Last Post: 10-07-2009, 01:25 PM
  5. need help to make this regular expression
    By aruna1 in forum New To Java
    Replies: 1
    Last Post: 04-12-2009, 09:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •