I have had the need to use regular expressions only a few times in the work that I have done. However, in those few times I discovered a very powerful form of expression that would enable me to do some extremely useful things.
The problem is that the language used for regular expressions is wrong - full stop.
It is wrong from a psychological point of view - using disembodied symbols provides a useful reference only to those with an eidetic memory.
Whilst the syntactic rules are clearly laid out, from my experience and what I have learnt from others, evolving a regular expression that functions successfully can prove to be a difficult thing to do in all but the most trivial situations.
This is understandable since it is a symbolic analog for set theory, which is a fairly complicated thing.
One of the things that can prove difficult is dissolving the expression that you are working on into its discrete parts. Due to the nature of the language, it is possible to read one regular expression in multiple ways if you don't have an understanding of its primary goal so interpreting other people's regexes is complicated. In natural language study I believe this is called pragmatics.
The question I'd like to ask then is this - is there such a thing as a regular expression compiler? Or can one even be built?
It could be possible to consider regexes, from a metaphorical point of view, as assembly language - there are some similarities. Could a compiler be designed that could turn a more natural language - a higher language - into regular expressions?
Then in my code, I could define my regexes using the higher level language in a header file and reference them where necessary using a symbolic reference. I and others could refer from my code to the header file and more easily appreciate what I am trying to achieve with my regexes.
I know it can be done from a logical point of view otherwise computers wouldn't be possible but if you have read this far then would you consider investing the time in realising it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…