我怎么知道“/”之前的第一个字符是哪个? asp.net vb.net [英] How do I know which are the first characters before "/"? asp.net vb.net
本文介绍了我怎么知道“/”之前的第一个字符是哪个? asp.net vb.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我有这样的字符串:
Dim temp As String = 批次235/689/45 pcs由vladut moraru在2015年10月15日预订
我要显示235/689
批次是:235/689
PCS是:45
我想只显示:235 / 689 of all string
我以为我会找到235/689/45,然后在最后一个/之后将其拆分并找到之前的值/,但是怎么样?
非常感谢!
解决方案
最简单的方法是使用正则表达式:
(?< Batch> \d + \ / \d +)\ /(?< PCS> \d +)。*
应该这样做。
正则表达式将是完美的:
Imports System.Text.RegularExpressions
// ...
Dim 输入作为 字符串 = 批次235/689/45 pcs由vladut moraru于2015年10月15日预订
Dim regexString 作为 字符串 = ^批次(?<批次> [\d] {3} / [\d] {3})/(?< PCS> [\d] {2})。*
Hi Guys,
I have a string like that:
Dim temp As String = "Batch 235/689/45 pcs booked out by vladut moraru on 10/15/2015"
I want to display 235/689
Batch is : 235/689
PCS is : 45
I want to display just : 235/689 of all string
I thought I'd find 235/689/45 and then to give it split after the last "/" and find value from before the "/", but how?
Thanks a lot!
解决方案
Simplest way is to use a Regex:
(?<Batch>\d+\/\d+)\/(?<PCS>\d+).*
Should do it.
A regular expression would be perfect for that:
Imports System.Text.RegularExpressions // ... Dim input As String = "Batch 235/689/45 pcs booked out by vladut moraru on 10/15/2015" Dim regexString As String = "^Batch (?<Batch>[\d]{3}/[\d]{3})/(?<PCS>[\d]{2}).*
这篇关于我怎么知道“/”之前的第一个字符是哪个? asp.net vb.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文