Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Regex: letters dot and space only

hassimkhan
Explorer
0 Kudos
4,188

Hello expert,

have an input field which should accept only letters, '.' and space (see image below). here is my code so far.


FIND FIRST OCCURRENCE OF REGEX '[^a-zA-Z]*' IN makt-maktx.

   IF sy-subrc = 0.

     MESSAGE e012.

   ENDIF.


makt-maktx is the field on screen.


Help please

7 REPLIES 7

Former Member
0 Kudos
510

Hi Hassim

Try this '^[a-zA-Z ,]*$'.

regards,

Archer

former_member201275
Active Contributor
0 Kudos
510

I don't understand your question, the code you have does what you ask so where is the issue?

0 Kudos
510

Hi Glen,

the REGEX doesn't fit the requirement.

Regards,

Klaus

0 Kudos
510

Ok. I don't understand regex so well, was just trying to find out exactly why. As they only want to allow letters '.' and space, and the code pasted returns subrc = 0, so i assumed it was fine.

Hopefully i will learn something from this post.

former_member195402
Active Contributor
0 Kudos
510

Hi Hassim,

please try this:

'^[a-zA-Z/s/.]+[/s]*$'

or

'^[a-zA-Z]+[a-zA-Z/s/.]+[/s]*$'

Regards,

Klaus

0 Kudos
510

space is /s, i forgot this.

0 Kudos
510

space is also space.

Replace your FIND statement with this.

FIND REGEX '[^a-zA-Z \.]' IN makt-maktx.


In regex, dot matches any character, and to match actual dot, you need to escape it using backslash.