Skip to content

Instantly share code, notes, and snippets.

@setap
Last active August 29, 2015 14:09
Show Gist options
  • Select an option

  • Save setap/a7422ea1d76356968a54 to your computer and use it in GitHub Desktop.

Select an option

Save setap/a7422ea1d76356968a54 to your computer and use it in GitHub Desktop.
Public Function RgxDfx(astring As Range) As String
Dim re As RegExp
Dim tempString
Set re = New RegExp
re.Pattern = "\d+"
re.Global = True
re.IgnoreCase = True
Set objMatches = re.Execute(astring)
RgxDfx = objMatches.Item(0).Value
End Function
Public Function RgxCity(astring As Range) As String
Dim re As RegExp
Dim tempString
Set re = New RegExp
re.Pattern = "[(](\d+)[)]"
re.Global = True
re.IgnoreCase = True
RgxCity = re.Replace(astring, "")
End Function
Public Function Rgx1stRange(astring As Range) As String
Dim re As RegExp
Dim tempString
Set re = New RegExp
re.Pattern = "(\d+)[-](\d+)"
re.Global = True
re.IgnoreCase = True
Rgx1stRange = re.Replace(astring, "$1")
End Function
Public Function Rgx2stRange(astring As Range) As String
Dim re As RegExp
Dim tempString
Set re = New RegExp
re.Pattern = "(\d+)[-](\d+)"
re.Global = True
re.IgnoreCase = True
Rgx2stRange = re.Replace(astring, "$2")
End Function
Public Function RgxCityFromRegion(astring As Range) As String
Dim re As RegExp
Dim tempString
Set re = New RegExp
re.Pattern = "(\S+)\s+([\S\s]+)"
re.Global = True
re.IgnoreCase = True
RgxCityFromRegion = re.Replace(astring, "$1")
End Function
Public Function RgxRegionFromCity(astring As Range) As String
Dim re As RegExp
Dim tempString
Set re = New RegExp
re.Pattern = "(\S+)\s+([\S\s]+)"
re.Global = True
re.IgnoreCase = True
RgxRegionFromCity = re.Replace(astring, "$2")
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment