stevenryals
Member
- Joined
- May 21, 2014
- Messages
- 5
- Programming Experience
- Beginner
I have been beating myself up over this, I can not seem to get this to work.
I am passing a string into a function to parse the string.
1) i am replacing all "|" with vbCrLf
2) there are instances of UserNames and I need to replace them with "internallink://action/username"
(this will trigger a local program to link to a user within the system)
This is a windows form application and is displaying notes.
I've tried about 50 different iterations of this, but here is my current code.
I have had absolutely zero luck with adding this link.. (currently as you see I have some lines commented out, but I've defo tried them in many iterations)
Any thoughts or direction would be extremely appreciated..
Thanks
I am passing a string into a function to parse the string.
1) i am replacing all "|" with vbCrLf
2) there are instances of UserNames and I need to replace them with "internallink://action/username"
(this will trigger a local program to link to a user within the system)
This is a windows form application and is displaying notes.
I've tried about 50 different iterations of this, but here is my current code.
VB.NET:
Public Sub ParseNotesHelper(ByRef PassedNotes As String)
' separate notes into individual lines separated by line break
PassedNotes = PassedNotes.Replace("|", vbCrLf & vbCrLf)
' add link to each user id within passed note string
Dim nameregex As Regex = New Regex("[A-Z]* [A-Z]*: ", RegexOptions.IgnoreCase)
' regex to grab text within any parentheses
Dim uidregex As Regex = New Regex("\((.*?)\)", RegexOptions.IgnoreCase)
' regex to be more specific to the setup of the user name/user id
Dim uidregex2 As Regex = New Regex("((?:[a-z][a-z]*[0-9]+[a-z0-9]*))", RegexOptions.IgnoreCase)
Dim i As Integer = 0
For Each user As Match In uidregex2.Matches(PassedNotes)
'Dim linklbl As New LinkLabel
Dim tempid As String = user.ToString()
Dim userid As String
Dim linkstring As String
userid = tempid.Trim("("c, ")"c)
'linklbl.Text = userid
linkstring = "internalApplication://action/" + userid
'Dim indexstart As Integer = user.Index
'Dim indexend As Integer = indexstart + 6
'Dim link As LinkLabel.Link = linklbl.Links.Add(indexstart, indexend, linkstring)
Regex.Replace(user.Value, "((?:[a-z][a-z]*[0-9]+[a-z0-9]*))", linkstring)
i = i + 1
Next
End Sub
I have had absolutely zero luck with adding this link.. (currently as you see I have some lines commented out, but I've defo tried them in many iterations)
Any thoughts or direction would be extremely appreciated..
Thanks