我有一个休息URL作为字符串-> rest/dashboard/person/hari/categrory/savingaccount/type/withdraw
在这种情况下,我必须获得人员和类别之间的值以及类别和类型之间的值。因为这些值会动态变化
休息/仪表板/人/ {{}} /类别/ {{}} /类型/退出
我尝试了string.gsub(mystring, "([%w]+%/)([%w%d]+)")
。但这似乎不是正确的浪费
请帮助
答案 0 :(得分:3)
string.match
(具有捕获功能)是完成任务的正确工具。
试试这个:
s="rest/dashboard/person/hari/category/savingaccount/type/withdraw"
print(s:match("/person/(.-)/category/(.-)/type/"))
答案 1 :(得分:2)
您可以按照建议使用惰性点Private Sub Text757_Click()
Dim Remarks757 As Variant
Remarks757 = DLookup("Remarks", "QueryDataPaveAll", "[YrRated] = Forms![FormDataEntryPave]![TextYrRated]" And "[RdSecNo] = Forms![FormDataEntryPave]![TextRdSecNo]")
If IsNull(Remarks757) Then
MsgBox "No Record Found"
Else
Me.Text757 = Remarks757
End If
End Sub
或否定的字符类.-
[^/]+