jknj72
asked on
And yet another piece of logic on LCF function
Pertains to Question ID: 28685124
One more piece of logic that I need with my function that returns the last company after variations of LCF. Now they want me to look for LCF and if it has a character after it then its a valid company.
Example: 'LCFY HOBOKEN LLC Y HOSPITALITY LLC'
That's a valid company but it has the LCF that we are looking for in it? Is there anyway we can look for a-z and if it is the next character then return the whole thing back as if it were a valid company?
One more piece of logic that I need with my function that returns the last company after variations of LCF. Now they want me to look for LCF and if it has a character after it then its a valid company.
Example: 'LCFY HOBOKEN LLC Y HOSPITALITY LLC'
That's a valid company but it has the LCF that we are looking for in it? Is there anyway we can look for a-z and if it is the next character then return the whole thing back as if it were a valid company?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>I do a trim before I return it. If not, let me know what your talking about and Ill let you know.
I meant the trim. I had to add it to what I posted to 'trick' it into working.
I meant the trim. I had to add it to what I posted to 'trick' it into working.
ASKER
Well I think it is working but im doing additional testing.
I hate to ask but is there any way you could briefly explain what is going on and what some of these special characters mean and what they are dong? Sorry to be a pain
Regexp_replace(
Regexp_replace (Regexp_replace(' ' || col1 || ' ', 'L[^[:alnum:] ]?C[^[:alnum:] ]?F[^[:alnum:] ]?',
'LCF'
, 1, 0,
'i'),
'LOST CONTENT FOR|LOST CONTRACT_FOR'
, 'LCF'
, 1, 0, 'i')
, '(.*LCF[ ])(.*$)', '\2')
I hate to ask but is there any way you could briefly explain what is going on and what some of these special characters mean and what they are dong? Sorry to be a pain
Regexp_replace(
Regexp_replace (Regexp_replace(' ' || col1 || ' ', 'L[^[:alnum:] ]?C[^[:alnum:] ]?F[^[:alnum:] ]?',
'LCF'
, 1, 0,
'i'),
'LOST CONTENT FOR|LOST CONTRACT_FOR'
, 'LCF'
, 1, 0, 'i')
, '(.*LCF[ ])(.*$)', '\2')
>>Sorry to be a pain
No problem. It's part of the learning process. Regular Expressions used to confuse me. Many still do but I'm more comfortable with them these days.
>>briefly explain what is going on
Briefly? Nope and I might get the 'official' terminologies incorrect. I'll post how I remember them. It may not be what the 'world' calls them.
[:alnum:] -- is a character class for alpha-numeric characters. There are others but I'll let you Google them...
[] is a character group.
A ^ outside of a character group is "start of line".
Inside a character group it is a NOT.
SO, [^[:alnum:] ] means: anything NOT an alpha-numeric or a space (there is a space after the alnum class)
The ? at the end means it is "optional"
SO, L[^[:alnum:] ]? says: MATCH a letter "L" NOT followed by a alpha-numeric or a space.
Same for C and F. The replace then replaces ALL those matches with 'LCF'. It makes the rest of the string matching easier so you don't have to hard-code ALL possible combinations.
No problem. It's part of the learning process. Regular Expressions used to confuse me. Many still do but I'm more comfortable with them these days.
>>briefly explain what is going on
Briefly? Nope and I might get the 'official' terminologies incorrect. I'll post how I remember them. It may not be what the 'world' calls them.
[:alnum:] -- is a character class for alpha-numeric characters. There are others but I'll let you Google them...
[] is a character group.
A ^ outside of a character group is "start of line".
Inside a character group it is a NOT.
SO, [^[:alnum:] ] means: anything NOT an alpha-numeric or a space (there is a space after the alnum class)
The ? at the end means it is "optional"
SO, L[^[:alnum:] ]? says: MATCH a letter "L" NOT followed by a alpha-numeric or a space.
Same for C and F. The replace then replaces ALL those matches with 'LCF'. It makes the rest of the string matching easier so you don't have to hard-code ALL possible combinations.
ASKER
Got it...that's actually what I was looking for an explanation on so Thanks....And everything works so thanks again!!
ASKER
Great job
ASKER
>> I hope you want any leading or trailing spaces removed?
Do you mean when getting the last company returned with spaces in front or behind the value ? I do a trim before I return it. If not, let me know what your talking about and Ill let you know.
Don't be so hard on yourself, you definitely know your stuff and I've learned a ton from all your help.