Results 1 to 2 of 2

Thread: .Net version of PHP's preg_match

  1. #1
    Addicted Member
    Join Date
    Apr 12
    Posts
    151

    .Net version of PHP's preg_match

    I've built some code in PHP before which reads a string of data and finds relevant parts based on selected criteria being a "match"

    How can I do this in .net (VB)?

    for example my string might be

    B/E1297G

    where the B/ with up to 6 charters is a order number?

  2. #2
    vb Coda .paul.'s Avatar
    Join Date
    May 07
    Location
    Chelmsford UK
    Posts
    16,471

    Re: .Net version of PHP's preg_match

    are you familiar with regex?

    vb.net Code:
    1. Imports System.Text.RegularExpressions
    2.  
    3. Public Class Form1
    4.  
    5.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    6.         Dim s As String = "some text B/E1297G some more text"
    7.         MsgBox(New Regex("\sB\/[A-Z]{1}\d{1,4}[A-Z]{1}\s").Match(s).Value)
    8.     End Sub
    9. End Class

Posting Permissions

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