2
完全字符串:尝试的IndexOf找到一个引号字符
PDFReference =
javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("InvestorL
ibrary_ILTocUC$LandingPanel$ildetail$lbNext", "", false, "", "/AO/Main.aspx?did
= [email protected]!nb2016!n160550603", false, true))
从以上我只是想捕捉[email protected]!nb2016!n160550603
所以这是我想:
$PDFDid = $PDFReference.Substring($PDFReference.IndexOf('?did = ') + 7, ($PDFReference.IndexOf('?did = ') + 7) - ($PDFReference.IndexOf("`"")))
我的问题是与$PDFReference.IndexOf("
“”)`,因为这似乎是干净的方法来捕获完整的字符串,但我得到一个错误
Exception calling "Substring" with "2" argument(s): "Index and length must refer to a location within the
string.
Parameter name: length"
任何想法如何执行IndexOf
一个"
人物?我试过使用"
,"
和"
,但是这些编码都没有工作。它不会识别报价。
令人惊叹。正是我需要的。我现在试着剖析一下,以确保我完全理解它向前迈进。谢谢! – Quanda
我编辑了我的答案,并添加了一些信息到您原来的问题。然而,正则表达式在这里很适合,因为你想捕获一个字符串,否则你必须使用一些'indexof'和'substring',这很难阅读恕我直言。 –
你可以在这里找到更多关于这个正则表达式的信息:https://regex101.com/r/iN9hR2/1 –