简体   繁体   English

如何在Aptana Studio 3中使用正则表达式更改匹配的组文本的大小写?

[英]How to change case of matched group text with regex in Aptana Studio 3?

I have the following HTML code: 我有以下HTML代码:

 <input type="radio" name="appearance" /> <label>Appropriate</label> 

I'm using the following regular expression to extract the text within the label tags (not a regex expert, so this works for me, please advice of better way): 我正在使用以下正则表达式提取标签标签中的文本(不是正则表达式专家,因此这对我有用,请提出更好的建议):

(<input \btype="radio"\s\b\bname\b="[\w://.]*") \/>(\s+)(<label>(.*?)<\/label>)

I'm using the following to replace the code: 我正在使用以下代码替换代码:

$1 value=\"$4\"\>$2$3

This changes the original HTML to: 这会将原始HTML更改为:

 <input type="radio" name="appearance" value="Appropriate"> <label>Appropriate</label> 

However, I want the value, "Appropriate" in this case, to be lowercase. 但是,我希望这种情况下的“适当”值是小写的。 I have tried adding \\L with no luck. 我尝试添加\\ L,但没有运气。

Any help is appreciated. 任何帮助表示赞赏。

Thanks. 谢谢。

If you're doing this in JavaScript, you can just use tolowerCase() in 如果您使用JavaScript进行此操作,则可以只使用tolowerCase()
the callback function. 回调函数。

 var input = '\\ <input type="radio" name="appearance" />\\n\\ <label>Appropriate</label>'; var output = input.replace( /(<input[ ]\\btype="radio"\\s\\b\\bname\\b="[\\w:\\/\\/.]*")[ ]\\/>(\\s+)<label>(.*?)<\\/label>/, function( m,p1,p2,p3, p4 ) { return p1 + " value=\\"" + p4 + "\\"\\>" + p2+ "<label>" + p3.toLowerCase() + "</label>"; } ); console.log( output ); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM