on 10-22-2008 5:21 AM
Hi,
Is it possible to find out the POSITION OF Nth OCCURANCE OF A PARTICULAR CHARACTER IN A STRING in crystal reports?
Eg:
I have a string abcdabcdabcd
Now I want to know the position of the 2nd occurance of u2018au2019 in the string u2018abcdabcdabcdu2019
You must do it in sql query with using charindex, something like
declare @string varchar(100)
declare @searched varchar(1)
select @searched = 'a'
select @string = 'abcdabcdabcd'
select charindex(@searched, @string, charindex(@searched, @string, 1) +1)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
dim MainStr as String=u2018abcdabcdabcdu2019
dim SubStr as String='a' 'Give which alphabet do you want.
dim Num as integer=2 'Give which 'a' do you want. i gave for second a.
dim ResultStr as string
dim ResultNum as integer=1
dim Position as integer=0
for i as integer=0 to MainStr.length-1
ResultStr=MainStr.SubString(i,1)
if ResultStr=SubStr then
ResultNum+=1
if ResultNum=Num then
position=i+1
exitfor
endif
endif
next
hope this solves your problem
regards,
varma
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I want to achieve the following sql code in crystal reports XI syntax:
instr(OTNAME,'.',1,4)
(This implies that: the 4th occurance of '.' is to be searched from OTNAME starting from position 1)
The value of OTNAME is like this: '73.2.700.710.U.BASE.F.I.5.6.5.2134.1.2'
Please help me find a way to achieve the above in crystal reports XI
User | Count |
---|---|
102 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.