123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- /*##############################################################################
- HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- ############################################################################## */
- import lib_stringlib;
- lb(string l, string r) := length(trim(l)) > length(trim(r));
- export Lead_contains(string l, string r) := if( lb(l,r),
- r=l[1..length(trim(r))],
- l=r[1..length(trim(l))]);
- export Tails(string50 l, string50 r) := length(trim(l))>=length(trim(r)) and
- l[length(trim(l))-length(trim(r))+1..length(l)] = r;
- export StripTail(string l, string r) := if ( Tails(l,r),
- l[1..length(trim(l))-length(trim(r))],
- l );
- export string StripUptoWord(string s, integer n) := if ( lib_stringlib.stringlib.stringfind(s,' ',n)=0,
- '',
- s[lib_stringlib.stringlib.stringfind(s,' ',n)+1..length(s)]);
- sp(string s,integer1 n) := if( lib_stringlib.stringlib.stringfind(s,' ',n)=0,
- length(s),
- lib_stringlib.stringlib.stringfind(s,' ',n) );
- export string word(string s,integer1 n) := if ( n = 1,
- s[1..sp(s,1)],
- s[sp(s,n-1)+1..sp(s,n)]);
|