【发布时间】:2014-03-13 01:06:55
【问题描述】:
我正在尝试做同样的事情:Find The Common Occurrences Of Words In Two Strings 但我希望它在 VB.net 中。
var tester = "a string with a lot of words";
function getMeRepeatedWordsDetails ( sentence ) {
sentence = sentence + " ";
var regex = /[^\s]+/g;
var regex2 = new RegExp ( "(" + tester.match ( regex ).join ( "|" ) + ")\\W", "g" );
matches = sentence.match ( regex2 );
var words = {};
for ( var i = 0; i < matches.length; i++ ) {
var match = matches [ i ].replace ( /\W/g, "" );
var w = words [ match ];
if ( ! w )
words [ match ] = 1;
else
words [ match ]++;
}
return words;
}
console.log ( getMeRepeatedWordsDetails ( "another string with some words" ) );
这是我目前所拥有的:
Dim tester As String = "a string with a lot of words"
sentence = sentence & " "
Dim regex As New Regex("/[^\s]+/g")
Dim m As Match = regex.Match(tester)
'not working
Dim regex2 As Regex = New Regex("(" + regex.Match(tester).join("|") + ")\\W", "g")
你能帮我把它放到 VB.net 中吗?
【问题讨论】:
标签: javascript regex vb.net