我有一个字符串In [183]: Arr=sparse.random(1000,1000,.001)
In [184]: (1-np.in1d(np.arange(Arr.shape[1]),Arr.col)).any()
Out[184]: True
In [185]: (1-np.in1d(np.arange(Arr.shape[1]),Arr.col)).sum()
Out[185]: 367
In [186]: timeit 1-np.ones(Arr.shape[0],dtype=bool)*Arr.astype(bool)
1000 loops, best of 3: 334 µs per loop
In [187]: timeit 1-np.in1d(np.arange(Arr.shape[1]),Arr.col)
1000 loops, best of 3: 323 µs per loop
In [188]: timeit 1-(Arr.col==np.arange(Arr.shape[1])[:,None]).any(axis=1)
100 loops, best of 3: 3.9 ms per loop
In [189]: timeit (Arr!=0).sum(axis=0)==0
1000 loops, best of 3: 820 µs per loop
。我需要将字符串作为com.test.edu.personal.SomeException: this is some error: test message
。
我的代码遇到了麻烦:
SomeException: this is some error
我得到declare @col varchar(100)
set @col = 'com.test.edu.personal.SomeException: this is some error: test message'
SELECT
SUBSTRING(@col,
LEN(@col) - CHARINDEX(':', @col) - CHARINDEX(':', REVERSE(@col)),
LEN(@col) - LEN(LEFT(@col, CHARINDEX ('.', @col))) - LEN(RIGHT(@col, LEN(@col) - CHARINDEX (':', @col))));
- 我在这里遗漏了一些东西
答案 0 :(得分:0)
declare @col varchar(100)
set @col = 'com.test.edu.personal.SomeException: this is some error: test message'
Select Substring(@col,Len((substring(@col,1,charindex(':',@col)))) - CharIndex(Reverse('.'), Reverse((substring(@col,1,charindex(':',@col)))))-len('.')+3 ,len(@col))
返回
SomeException: this is some error: test message