开发者

How to use Regex.Split on this String?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜