cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements

611
Views
4
Helpful
3
Replies
gfolens
Enthusiast

CMS LDAP import and filter on ipPhone number

I'm importing users from AD using the API.

The field ipPhone contains the number of the user in E.164. But for the space id (coSpaceCallIdMapping) I would like to take the last 6 digits of this number and put a prefix.

So after some investigation I constructed the following SED command to achieve this: 88$ipPhone|'/(\d{6}$)/\1/'$

Normally this should extract the last 6 digits of the ipPhone files contents.

But still the result stays 88+3241234567.

Any ideas which pattern to use?

3 REPLIES 3

Try the following regex:

88$ipPhone|'/^\+(.{4})//'$

The result of the regex will return 88234567, removing +3241 from the start of the phone number, and adding the prefix 88.

  • ^ will match at the start of the pattern
  • \+ will match +
  • .{4} will match any four characters

Hi, thanks for the input but apparently the provided regex filters and returns the first 5 characters.

I've slightly adjusted the regex to: 88$ipPhone|'/^+.{4}//'$ and now the +3241 are removed and the obtained string is now 88234567.

Seems the API is not fully SED compliant.

I tested these regex on a MAC all with same results:

echo +3271325476 | sed 's/^\+.\{4\}//'

echo +3271325476 | sed 's/^.\{5\}//'

echo +3271325476 | sed 's/^\+[0-9]\{4\}//'

Apparently the escape characters are not needed and not working on CMS.

Glad you got it working and able to get the result you want.  I tested the regex best I could in my environment, I'm new to SED myself, so it was learning curves for me.

Don't forget to mark your question as answered, by setting relevant replies (if any) as the correct answer.

Create
Recognize Your Peers
Content for Community-Ad