Regular expressions: Difference between revisions
Content added Content deleted
m (→{{header|Haskell}}: lang tag) |
m (→{{header|Java}}: lang tag) |
||
Line 295: | Line 295: | ||
Test |
Test |
||
<lang java> String str = "I am a string"; |
|||
if (str.matches(".*string$")) { |
if (str.matches(".*string$")) { |
||
System.out.println("ends with 'string'"); |
System.out.println("ends with 'string'"); |
||
} |
}</lang> |
||
Substitute |
Substitute |
||
<lang java> String orig = "I am the original string"; |
|||
String result = orig.replaceAll("original", "modified"); |
String result = orig.replaceAll("original", "modified"); |
||
// result is now "I am the modified string" |
// result is now "I am the modified string"</lang> |
||
=={{header|JavaScript}}== |
=={{header|JavaScript}}== |