Using regexp to parse plot's LineSpec
Mostra commenti meno recenti
Hello, I'm trying to parse the LineSpec string used in plot(...,LineSpec).
LineSpec specifies the plot line's style/marker/color, for example "-or". Some of the possible options are:
- Style: - | -- | .- | -. | :
- Marker: [o+*._|sd^v><]
- Color: [rgbcymkw]
So far I had some success in regexp with
regexp(str,'((-[-|.]?)|:|(.-))?+[o+*._|sd^v><]?+[rgbcymkw]?','match','once')
and
regexp(str,'^(?:([rgbcymkw.:-*sodv^><][^.]*)(?!.*\1))+$','match','once')
or by splitting and erasing the string at each stage (not an elegant solution). However, this method parses also words, is not strict against repetitions and fails by changing the order.
I am trying to split a LineSpec into its three components, but just having regexp recognize a string as a valid LineSpec would be great. Would it possible to do this with a regexp pattern?
Thank you in advance.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Labels and Annotations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!