|
|
|
Регулярные выражения: отменить дейтсвие всех спецсимволов без излишних телодвижений
|
|||
|---|---|---|---|
|
#18+
jdk1.4 Суть проблемы в том, что в 1.4 методы у класса String replaceAll и пр. теперь основываются на регулярных выражениях public String replaceAll(String regex, String replacement) Replaces each substring of this string that matches the given regular expression with the given replacement. An invocation of this method of the form str.replaceAll(regex, repl) yields exactly the same result as the expression Pattern.compile(regex).matcher(str).replaceAll(repl) Так что теперь чтобы выполнить простую замену message.replaceAll(oldString, newString); нужно в oldString замаскировать все потенциальные спец. символы, а их много и делать это ручками геммор. В php например есть функция preg_quote которая это делает, есть ли подобная штука в Яве? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 22.11.2004, 12:29 |
|
||
|
|

start [/forum/topic.php?fid=59&fpage=830&tid=2153401]: |
0ms |
get settings: |
9ms |
get forum list: |
18ms |
check forum access: |
4ms |
check topic access: |
4ms |
track hit: |
39ms |
get topic data: |
11ms |
get forum data: |
3ms |
get page messages: |
48ms |
get tp. blocked users: |
2ms |
| others: | 195ms |
| total: | 333ms |

| 0 / 0 |
