24
Views
5
Comments
Solved
Find Alphabets in string

Hi All, Can any one tell me how to find Alphabets only from string. 

like - mystring123sting#$r\

Output- mystringstingr


Thanks in advance 

Amogh

Rank: #95
Solution

Hi Amogh,


You can create a function using Regex_Replace from Text.

So first, you reference the action:

Then you call the Regex_Replace like on the image below with the Pattern [0-9]|[$&+,:;=?@#|'<>.^*()%!-]|\\

Basically it will replace numbers or special characters by nothing, in other words it will eliminate them. The output of the function is what you need:


Hope it helps.

Cheers,

João

Rank: #90

Hi Amogh,

You can simply use JavaScript 

function alphaOnly(a) {
    var b = '';
    for (var i = 0; i < a.length; i++) {
        if (a[i] >= 'A' && a[i] <= 'z') b += a[i];
    }
    document.getElementById("demo").Value=b;
    //$('#InputID').val(b);
}

you can use this function on script  or use in JavaScript widget.

Hope this will help you.

Regards

Rahul

Rank: #95
Solution

Hi Amogh,


You can create a function using Regex_Replace from Text.

So first, you reference the action:

Then you call the Regex_Replace like on the image below with the Pattern [0-9]|[$&+,:;=?@#|'<>.^*()%!-]|\\

Basically it will replace numbers or special characters by nothing, in other words it will eliminate them. The output of the function is what you need:


Hope it helps.

Cheers,

João

Rank: #116

Hello Amogh,


You can use a simple JavaScript node to implement your own Regular Expression. Something like this should do the trick:

The Pattern used was [^A-Za-z], which basically detects everything that is not between A - Z and a - z. If so, replace it by an empty string.

Expected result:


Please refer to attached OML.


Hope that this helps you!


Kind regards,

Rui Barradas

AlphabetsOnly.oml

mvp_badge
MVP
Rank: #18

Several solutions, consider this when executing if you need this server side then the solution form João is the best one. The one from Rui works best for Reactive and Mobile on the client side.


Rank: #95

Hi,


Daniël's point and the number of Regex questions always coming up in Forums here and there made me think we were lacking a component about Regex to provide:

  • How to use both Client side (as Rui did) or Server side (as I did);
  • A sandbox to test (avoiding constant publishing and refreshing dependencies due to the error-prone nature of the RegEx syntax);
  • A quick solution for the most common cases (validate dates, emails, get numbers, etc.)

Based on that, I created a Regex How-To component which hopefully will help on the aforementioned scenarios.


Cheers,

João