0

数字"Reference=" in the enclosed?の前後の文字数や数字の長さ(文字や数字の場合もあります)を知ることはできませんが、常に

After "Reference=" Before ",Description"

Object=CTSENORaanG,Reference=0000021357,Description=Test,Currency=EUR,Initial_Date=15Aug2011....

文字列は大量の行を持つテーブルからのものであり、各行の参照を別のテーブルに挿入する必要があります

4

3 に答える 3

2

SQLサーバー

declare @str varchar(1000)
set @str='Object=CTSENORaanG,Reference=0000021357,Description=Test,Currency=EUR,Initial_Date=15Aug2011....';

select substring(col,1,charindex(',',col)-1) from
(
select substring(@str,charindex('Reference=',@str)+10,100) as col
) as t;

MySQL

set @str:='Object=CTSENORaanG,Reference=0000021357,Description=Test,Currency=EUR,Initial_Date=15Aug2011....';

select substring(col,1,locate(',',col)-1) from
(
select substring(@str,locate('Reference=',@str)+10,100) as col
) as t;
于 2012-07-12T07:28:49.017 に答える
1

区切り文字が常にコンマ,である場合は、文字列を分割できます。次に、区切られた部分文字列も と一致する場合は、さらに分割できます=。釣り上げるとReference、同等の価値が得られます。

/* your test string */
string s = "Object=CTSENORaanG,Reference=0000021357,Description=Test,Currency=EUR,Initial_Date=15Aug2011";     
string[] arr = s.Split(',');

/* will contain the value you're looking for */    
string target = String.Empty;

foreach (string item in arr)
{
   string[] entry = item.Split('=');
   if (entry.Length == 2 && entry[0] == "Reference")
   {
      target = entry[1];
      break;
   }
}
于 2012-07-12T07:18:35.007 に答える
0
use
pos = explode(",",string);
foreach(pos as po)
{
    p = explode("=",po)
    i=0;
    foreach(p as a)
    {
        if(a[i]== Reference)
        {
            echo p[i+1];
            i++;
        }
    }
}
于 2012-07-12T07:26:31.970 に答える