• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Search for a particular regex in String

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I need to search for a string "<script" in java Tag class. I have used following logic. urlAsString is the String in which i am searching for the "<script" string.

if(urlAsString.matches([[^ ] ]*<[ ]*(?i)script[[^ ] ]*))
{
urlAsString = "Page contains javascript";
}

In short, i dont want to allow "<script" in urlAsString except it is used as "<script>parent.close();</script>". If it is used in this manner, then i need to allow it otherwise "<script" should not be there.

can anyone guide me on this?
reply
    Bookmark Topic Watch Topic
  • New Topic