Home > Net >  How to replace content with a regular expression
How to replace content with a regular expression

Time:02-17

CodePudding user response:

(0 | \ d {1, 2} | 100) (\ d +) \ \ s + d (\ \) 2=(\ w +)
Respectively in three groups (1, 2, 3) corresponding: scores, student id, name

CodePudding user response:

 Private Sub Button1_Click (sender As Object, As EventArgs e) Handles for. Click 
Dim STR As String="9901 d (01)=threes
88101 d (101)=wu3 da4 lang2
Adsfd
Amplifier amplification "
Dim the MC As System. Text. RegularExpressions. MatchCollection=System. Text. RegularExpressions.. Regex Matches (STR, "(0 | \ d {1, 2} | 100) (\ d +) \ \ s + d (\ \) 2=(\ w +)")
For Each m the As System. Text. RegularExpressions. Match the MC In
MessageBox. Show (" name: "+ m.G roups. (3) the Value + Environment. The NewLine +" student id: "+ m.G roups. (2) the Value + Environment. The NewLine +" score: "+ m.G roups (1). The Value)
Next
End Sub

CodePudding user response:

reference 1/f, rabbit party at large response:
(0 | \ d {1, 2} | 100) (\ d +) \ \ s + d (\ \) 2=(\ w +)
Respectively in three groups (1, 2, 3) corresponding: scores, student id, name

I have written in vb, but don't know how to express in the vb.net
D (101)=wu3 da4 lang2 is a dictionary, not a part of the data, the data is only on the left side of the column of
I want to realize the matching line by line, and then according to the dictionary to replace the student id
1===dim aaa as string=read in a row aaa, this step is mainly the following code has to do not write
2===set expressions (\ d {2, 3}) (\ d {2, 3})
3===if aaa and expression match then
Returns the second value (student id) as the key in the dictionary d lookup name
Returns the first value in the array arr (0), the name in the array arr (1)
End the if
Perhaps is such a process
  • Related