开发者

How to use Regex.Split on this String?

开发者 https://www.devze.com 2022-12-17 09:53 出处:网络
Does anyone know how to write a Regex.Split in order to convert 开发者_如何学JAVA{video=\"my/video/file.flv,my/location.jpg\"}

Does anyone know how to write a Regex.Split in order to convert

开发者_如何学JAVA{video="my/video/file.flv,my/location.jpg"}

into

  1. my/video/file.flv
  2. my/location.jpg


Like this:

new Regex(@"[{="",}]").Split(@"{video=""my/video/file.flv,my/location.jpg}").Where(s => s.Length > 0)

EDIT: In VB:

Dim regex As New Regex("[{="",}]")
Dim myStr = "{video=""my/video/file.flv,my/location.jpg}"

Dim results = regex.Split(myStr).Where(Function(s) s.Length > 0)


Have you considered using the Split function?

string x  = "{video=\"my/video/file.flv,my/location.jpg\"}";
string xx = x.Split(',');


This work around seems to have done the trick for me. Thoughts?

    Dim str As String = "this is exciting {video=""my/exciting/video.flv,my/refreshing/image.jpg""} this is refreshing"
    Dim regFind As String = "(?'text'\{video=""(.*)\""})"
    Dim matcher As Match = Regex.Match(str, regFind)

    Dim Matched As String() = (matcher.Groups("text").Value).Split(",")

    Dim video As String = Matched(0).Replace("{video=""", "")
    Dim jpg As String = Matched(1).Replace("""}", "")

    Response.Write(video)
    Response.Write("<br />")
    Response.Write(jpg)
0

精彩评论

暂无评论...
验证码 换一张
取 消