VS 2015 regex-VBForums
Results 1 to 3 of 3

Thread: regex

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2018
    Posts
    1

    Unhappy regex

    Hi,

    can anyone help me to find this regex pattern for this string

    <proj soc=”TTL-UY, GPL-UY” topo=”LTeGHG, CAR-UY”>

    I'm want to match a string embedded in double quotation marks

    output : TTL-UY, GPL-UY
    LTeGHG, CAR-UY

  2. #2
    Fanatic Member PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Newport, UK
    Posts
    662

    Re: regex

    If the string is simple " quotes then
    Code:
    ".+?"
    should work as a regex to match what is between the quotes.

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    21,560

    Re: regex

    Try this...

    Code:
    Imports System.Text.RegularExpressions
    
    Public Class Form1
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim s As String = "<proj soc=""TTL-UY, GPL-UY"" topo=""LTeGHG, CAR-UY"">"
            Dim matches() As Match = Regex.Matches(s, "(?<="")[A-Za-z\-(,\s)]+?(?="")").Cast(Of Match).ToArray
            MsgBox(String.Join(Environment.NewLine, Array.ConvertAll(matches, Function(m) m.Value)))
        End Sub
    
    End Class

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width