Home > front end >  Asp only take regular expressions matching the value of letters or Numbers, or Chinese how to take?
Asp only take regular expressions matching the value of letters or Numbers, or Chinese how to take?

Time:03-06

For asp regular expressions, not familiar to existing a string, as follows:

TestStr="lx_name u8282 u4E00 u7B2C=% % % % % 20% u4F1A u8BA1 u80FD u804C u3001 u5FF5 u6982 % % % % % % % u548C u76EE u7AE0 u4E00 u7B2C % % % % u6807%28% 20% u8FF0 u6982 u8BA1 u4F1A % % % % 29 & amp; Subject_id=44 & amp; Know_id=15222 & amp; Id=0 & amp; Num=33 & amp; Use_time=0 & amp; Exam_id=44 & amp; Agency_id=0 & amp; Status=1 & amp; Right_num=2 & amp; Data [0] [answer]=13 & amp; Data [0] [correct]=1 & amp; Data [0] [pid]=0 & amp; Data [0] [item_id]=1 & amp; Data [0] [type]=1 & amp; Data [0] [agency_id]=0 & amp; Data [1] [answer]=24 & amp; Data [1] [correct]=0 & amp; Data [1] [pid]=0 & amp; Data [1] [item_id]=2 & amp; Data [1] [type]=1 & amp; Data [1] [agency_id]=0 & amp; Data [2] [answer]=31 & amp; Data [2] [correct]=1 & amp; Data [2] [pid]=0 & amp; Data [2] [item_id]=3 & amp; Data [2] [type]=1 & amp; Data [2] [agency_id]=0 "

The parameter lx_name back into Chinese, I now want to use regular expressions to write a function that that any one parameter values , including the inside of the similar data array value [0] [type]=1 or data [1] [type]=1 or data [2] [type]=value of 2 ~
For example: I want to get the following parameter values,
Response. Write "title:" & amp; GetValue (testStr, "lx_name") & amp;"
"
Response. Write "paper ID:" & amp; GetValue (testStr, "exam_id") & amp;"
"
Response. Write "time of use:" & amp; GetValue (testStr, "use_time") & amp;"
"
Response. Write "the total number of questions:" & amp; GetValue (testStr, "num") & amp;"
"
Response. Write "whether it is right:" & amp; GetValue (testStr, "data [2] [correct]") & amp;"
"

Regular expressions, as follows:
The function GetValue (STR, u)
The Set re=New RegExp
re. The Pattern="" & amp; U&"=[" "]? (\ [/w] +) [^ & gt;] * "'//matches only digital num=33 expression
Re. Global=True 'search string matching for full text rather than just a
Re the IgnoreCase=True 'ignore case
Re. MultiLine=True

The Set matches=re. The Execute (STR)

If matches. Count> 0 then
GetValue=https://bbs.csdn.net/topics/matches (0). SubMatches (0)
End the if
End the function

But the result of the final output, can match the diagram below, the parameter "lx_name", there is a similar "data [2] [correct]" such an array of values, always can't get (my red line draw useful, is not value), what reason be? Who can help me, write a regular expression, right points to you ~

  •  Tags:  
  • ASP
  • Related