0

I am using Regex Patterns and I need to check that the beginning of the String is an HTML Simple Text and return that String. So for example:

Hello World!<TAG> &nsbp;

Should return:

Hello World!

BoltClock
  • 665,005
  • 155
  • 1,345
  • 1,328
Free Lancer
  • 990
  • 2
  • 15
  • 33

2 Answers2

3

Remember that if you're parsing large sections of text or entire files, you should force the String into a new reference otherwise you may get a memory leak due to substrings.

new String("Hello World!<TAG> &nsbp;".split("<")[0])
BoltClock
  • 665,005
  • 155
  • 1,345
  • 1,328
David O'Meara
  • 2,957
  • 24
  • 38
0
"Hello World!<TAG> &nsbp;".split("<")[0]

should return Hello World!.

thejh
  • 43,352
  • 16
  • 93
  • 105