Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

extract from a string

Status
Not open for further replies.

mart10

MIS
Nov 2, 2007
394
GB
I am using CR XI

I have a string containing OQxxxx,NQxxxx or NQxxxxx Note the xxx can be of variable length

I want to just extract just the part NQxxxxx or even better the xxxx part of the NQxxxxx bit at the end.
 
If you use

split('OQxxxx,NQxxxx or NQxxxxx', 'NQ')[3]

This returns xxxxx

If you replace above string with your filed you should get what you want.

Ian
 
I think the OP means the value like one of these 3 strings:
"OQxxxx"
"NQxxxx
"NQxxxxx"

If so ant you want everything after the first 2 characters, use this:

Mid({yourfield},3)

If you want the 4 right characters, use this:

right({yourfield},4)

If you want the first 4 XXXX after the first 2 characters, use this:

mid({yourfield},3,4)

Software Sales, Training, Implementation and Support for Macola, Synergy, and Crystal Reports. Check out our Macola tools:
 
If it is always 'NQ' then Try the following:

Code:
strreverse(extractstring(strreverse({@string}),'','QN'))

This would only work when the NQ is the last entry in the string but will suffice for any length.

'J

CR8.5 / CRXI - Discovering the impossible
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top