Tag: 正则预览模式: 普通 | 列表
10-03
12

Java过滤标点符号

package com.yy.test;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class StringUtil {

public   static   void   testReg(){  
         //先去掉标点,再合并空格  

查看更多...

Tags: 标点 符号 过滤 正则

分类:Java&Jsp | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 1035
09-07
08

JavaScript 中的replace方法,正则或字符串全部交替

第一次发现javascript中replace() 方法如果直接用str.replace("-","!") 只会替换第一个匹配的字符.

引用内容 引用内容
replace()
The replace() method returns the string that results when you replace text matching its first argument
    (a regular e­xpression) with the text of the second argument (a string).
    If the g (global) flag is not set in the regular e­xpression declaration, this method replaces only the first
    occurrence of the pattern. For example,

var s = "Hello. Regexps are fun.";s = s.replace(/\./, "!"); // replace first period with an exclamation pointalert(s);

查看更多...

Tags: JS replace all 正则

分类:Ajax/Js | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 322