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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search & Split

Status
Not open for further replies.

sachrath

Programmer
May 21, 2004
17
CH
Hi ,

I have 5 fields in a flat file named as x with a delimiter as '|' .

I pass this expression as a PATTERN SEARCH string as mentioned below ;

'(O\|[^F]\|X\|[^Y]\| *\|)'

I intend to create a new file y out of x for those records which satisfies the above PATTERN MATCH , but it fails to bring some of the records in the new file (y)as explained below .

This search string is able to bring all values for which field_2<> F
or
field_4<> Y , but is not able to bring those records for which the fields are NULL.

Any help
Sac .



 
Why not playing with awk as we've already showed you in your previous posts ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Agreed Sir ,

But here we have prepared reusable shell script which accepts the file name , PATERN MATCH string etc etc to search and split the files .

So , dont have much control over the type pf scripting .

 
'(O\|[^F]\|X\|[^Y]\| *\|)'
This search string is able to bring all values for which field_2<> F
or
field_4<> Y

I think the or should be read and

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
'(O\|[^F]\|X\|[^Y]\| *\|)'
This search string is able to bring all values for which field_2<> F
or
field_4<> Y


Yeah , its AND instead of OR .

But it doesnt work either.

Sac
 
What about this ?
'(O\|[^F]| *\|X\|[^Y]| *\| *\|)'

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
May be I am asking for a lot , even after the solution is in my hands but I am a lil perplexed .

Well , I have changed the search string which u had sent by a bit and it works

(O\|([^F]| *)\|(CSFPRODLONGB|CSFPRODTOKJP|CSTOKBRTOKJP)\|([^Y]| *))\| *\|)'

1.) But does that mean that "[^Y]" would be returning only those string for which a physical string <>Y and would not be returning NULL .

2.)Looking at the string i understand that ' *' represents a NULL value, so it would look for 0 or many spaces between the delimiters but why do we have a "\|" at the end of the expression .

Thx
Sac
 
Can someone explain what does the pattern expression do
(O\|[^F]\|X\|[^Y]\| *\|)'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top