Support forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_TopicIcon
How to remove the leading 0 on int numbers
sp_NewTopic Add Topic
March 6, 2020
8:37 pm
Henk Helmantel
Admin
Forum Posts: 1558
Member Since:
May 28, 2013
sp_UserOfflineSmall Offline

'regex:^0+replace:' is the correct regular expression to remove all leading zeros from a string.

If this does not work in your configuration I would like to see the configuration file of Diafaan SM Server (menu options 'File-Export-Configuration). You can send the file to email address dms@diafaan.com.

Regards, Henk

March 6, 2020
10:34 am
peter
Guest
Guests

regex:^0+replace:

i tested. no just leading zeros but all zero are removed.
eg.
0010999 -> 1999

February 14, 2020
9:40 am
Henk Helmantel
Admin
Forum Posts: 1558
Member Since:
May 28, 2013
sp_UserOfflineSmall Offline

Hello Peter,

To remove two leading zeros from the number:
regex:^00replace:

To change two leading zeros to a '+':
regex:^00replace:+

To remove all leading zeros from the number:
regex:^0+replace:

Regards, Henk

February 13, 2020
5:23 pm
peter
Guest
Guests

if no of digits following 0 varies, eg
004491239123 -> 4491239123
00618123812333 -> 618123812333

how to achieve using regex?

March 22, 2019
12:09 am
Verified
Guest
Guests

Ok resolved this with

regex:[^\d]replace:template:640[64]########;640[64]#########;640[64]##########;640[64]###########

March 21, 2019
11:56 pm
Verified
Guest
Guests

Status 300, Error: Invalid sms number: :64:0271231234

March 21, 2019
11:51 pm
Verified
Guest
Guests

Hi Henk,

I tried your example but messages still didnt send. I have added this

:template:0[+64]########;0[+64]#########;0[+64]##########;0[+64]###########

to the gateway and the number shows in the log as +64 027 123 1234. Presumably the above translation is converting to +64271231234 but nothing came through.

Many thanks
paul

March 13, 2019
10:47 am
Henk Helmantel
Admin
Forum Posts: 1558
Member Since:
May 28, 2013
sp_UserOfflineSmall Offline

You can add a (list of) normal number template(s) after the regular expression to change the number format further, e.g.:

regex:[^\d]replace:template:0[+44]#########;0[+44]##########

This template first strips the number of all non-digits with the regex/replace combination and then replaces the leading 0 with +44 for any numbers that have 10 or 11 digits with the two normal number templates at the end.

It is probably possible to do this with a single regex/replace combination as well but that requires more skills than I possess on regular expressions.

Regards, Henk

March 12, 2019
12:23 am
Verified
Guest
Guests

Hi there we have set up the server with a gateway and the following number template:

regex:[^\d]replace:

However, sometimes the user also enters the leading 0 so we end up with +countrycode 0 number

How can we ensure that 0 is removed because it causes chaos with the gateway?

Many thanks

Forum Timezone: Europe/Amsterdam
Most Users Ever Online: 820
Currently Online:
Guest(s) 4
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Member Stats:
Guest Posters: 696
Members: 0
Moderators: 0
Admins: 1
Forum Stats:
Groups: 2
Forums: 3
Topics: 1188
Posts: 4049
Newest Members:
, Henk Helmantel
Administrators: Henk Helmantel: 1558