Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular Expressions in Ada?

Tags:

regex

ada

I'm very new to Ada, and I'm trying to do some simple work with some text. All I want to do is read in a file, and strip out anything that isn't a letter, space, or new line. so removing all the punctuation and numbers. In other languages I would just create a simple [^a-zA-Z] regular expression, look at each character and delete it if it fit the RegEx, but I can't seem to find any documentation on RegEx's in Ada. So, are there RegEx's in Ada? If not, what's the best way for me to go about simple text editing like this.

thanks much, -jb

like image 693
jb. Avatar asked Dec 17 '22 05:12

jb.


2 Answers

if you are using the GNAT compiler, there are a set of packages called GNAT.RegExp, GNAT.RegPat and GNAT.Spitbol made for this task.

beware that it is not standard regexp ala perl but is based on SNOBOL4. however, it should not be very difficult to convert from one type of regular expression to another.

like image 70
Adrien Plisson Avatar answered Jan 04 '23 22:01

Adrien Plisson


You may want to go through this example, and just look for the characters you want to ignore and don't put them into the new string.

Which version of Ada are you using?

http://www.adaic.com/docs/95style/html/sec_8/8-4-7.html

like image 40
James Black Avatar answered Jan 05 '23 00:01

James Black