Home > Software engineering > For help: the end of the regular expression to extract text in the VBA
For help: the end of the regular expression to extract text in the VBA
Time:11-15
1. Type the 2. Type/manufacturer 3. Type/manufacturer/model A general regular expressions, to extract the final text Results: 1. Type the 2. The manufacturer is 3. Type
CodePudding user response:
Try this:
The \ w + $
CodePudding user response:
As always provide the regular expression solution:
Sub test () The Debug. Print getLast (" type ") The Debug. Print getLast (" type/factory ") The Debug. Print getLast (" type/manufacturer/model ") End Sub
The Function getLast (strIn As String) As String Dim TMP () As String TMP=Split (strIn, "/") GetLast=TMP (UBound (TMP)) End the Function
CodePudding user response:
If the abandon with three lines of code, then change to a line,
Sub test () The Debug. Print getLast (" type ") The Debug. Print getLast (" type/factory ") The Debug. Print getLast (" type/manufacturer/model ") End Sub
The Function getLast (strIn As String) As String GetLast=Split (strIn, "/"), UBound (Split (strIn, "/"))) End the Function