ChinaUnix.net
相关文章推荐:

c# string replace 正则

1 text = id,name 2 text = id,named UPDATE db SET text = replace( text, 'id,name', 'id,namec' ) 结果两条记录都被替换了,能不能只替换第一条? UPDATE db SET text = replace( text, 'id,name$', 'id,namec' ) UPDATE db SET text = replace( text, '[[::]]id,name[[::]]', 'id,namec' ) 都不管用。。。

by freeand - MySQL - 2011-09-27 17:15:35 阅读(4881) 回复(3)

相关讨论

我想替换/dir/包含下级所有目录为空,请问这个正则该怎么写,谢谢

by sumbo - PHP - 2006-07-21 11:27:32 阅读(1552) 回复(8)

$str="[TXT]测试[/TXT][TXT]森[/TXT][IMGS]3dg.gif[/IMGS]"; $find = array("/\[TXT\](.+?)\[\/TXT\]/si"); $replace = array("1","2"); $strs = preg_replace($find,$replace,$str); 我要效果是[TXT]1[/TXT][TXT]2[/TXT][IMGS]3dg.gif[/IMGS]变成这样!请如何用preg_replace依替换数组值方式替换了? [ 本帖最后由 HonestQiao 于 2006-7-5 21:50 编辑 ]

by peterdocter - PHP - 2006-07-06 21:47:09 阅读(1341) 回复(6)

比如字符串: var strText = "bb hello bb 12345"; 如何从尾部替换 bb 一次为 ==> "bb hello jake 12345" 看了 replace()资料 都是从头开始替换的。 谢谢! [ 本帖最后由 sundycindy 于 2008-6-30 15:21 编辑 ]

by sundycindy - Web开发 - 2008-06-27 10:22:59 阅读(2603) 回复(2)

[code] smg smg《1/7》 smg《1/7》栏目 SMG smg《七分之一》 smg《真情实录》 smg东视广角 smg深度105 smg真情实录 东方卫视-东方夜新闻 东方卫视-东视广角 东方卫视《1/7》 东方卫视《东方新闻》[/code] [code] $search= array("*.smg.*", "*.东方卫视.*"); $SourceF=preg_replace("$search","东方卫视",$SourceF);[/code] 上面的替换怎么不能正常执行呢?? 我应该把/i加到什么位置...

by 061107 - PHP - 2008-01-03 11:14:19 阅读(2728) 回复(7)

[code]$string = "from 222.263.261.261 (kunming@abc.com.cn@222.263.261.261) by mail.def.net.cn (envelope-from , uid 89) with qmail-scanner-2.01"; echo preg_replace($pattern, $replacement, $string);[/code] 求两组正则写法,使之能获取 $string 中的 222.263.261.261 和 “<”“>”之间的 kunming@abc.com.cn 谢谢!

by 红雨 - PHP - 2007-01-08 15:58:38 阅读(1183) 回复(3)

想使被搜索的词高亮。但必须只是那个词。如:要搜索"you" 这个词,但"your" 或 "yours" 不要高亮。 同时,在HTML tag 中的词也不要高亮。 $tt='/(?!<.*?)\b' . $key_word . '\b(?![^<>]*?>)/is'; $pre_pattern=""; $post_pattern=""; preg_replace($tt,$pre_pattern . "\\0" . $post_pattern, $string_body); 在第一句中,若去掉\b 就可以,否则,老是在文件尾报错: Parse error: parse er...

by schrosource1 - PHP - 2005-12-08 10:59:36 阅读(1011) 回复(2)

Hi, Hope any one could help me. I have following 2 scripts just like in C style: modifydoc.sh: RECLEN=248 STPOINT=145 STLENGTH=6 TARGETST=$1 NEWST=$2 OLDFILE=$3 NEWFILE=$4 FZ=`ls -l ${OLDFILE} | awk '{print $5}'` RECNO=`expr ${FZ} / ${RECLEN}` STPOINT1=`expr ${STPOINT} - 1` RESTPOINT=`expr ${STPOINT} + ${STLENGTH}` RESTLEN=`expr ${RECLEN} - ${RESTPOINT} + 1` FILEST=`tail ${OLDFILE}` i=1 NEWST...

by schrosource_yua - Shell - 2009-08-13 19:44:24 阅读(1012) 回复(0)

正则表达式中的特殊符号及正则表达式的几种方法(replace,test,search) 一 正则表达式的正文。 正则表达式中使用了特殊符号。下面我就将各种符号以及其意义和用法简单的介绍一下(说明:"X以上包括X"): \ 表示在其后的文字是特殊符号。例:"n"和"n"是一致的。"\n"和换行符是一致的。 ^ 和输入的开始一致。 $ 和输入的结尾一致。 * 与此符号之前的文字0次以上相同的话,两者一致。例:"zo*"和"zoo","z"都一致。 + 与此...

by militala - php文档中心 - 2009-01-13 09:52:01 阅读(2176) 回复(0)

filehandler = file(self.filepath,'r') filenew = file(self.newfile,'w') while(1): strtemp = filehandler.readline() if not strtemp:break strtemp.replace('(','[') strtemp.replace(')',']') filenew.write(strtemp) filehandler.close() filenew.close() 得到结果。。是没有 replace 过的????? 为什么????

by ssqhan - Python - 2009-08-17 09:38:46 阅读(1254) 回复(2)

string str; str = "hello";//1 str = new string("hello");//2 分别循环10000000次,所用时间(millis)分别为90, 9083. 具体细节不清楚,关注中.... 本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/11783/showart_59017.html

by nomigdweiwei - Java文档中心 - 2005-11-28 10:13:00 阅读(767) 回复(0)