I have a string that contains the numerous tags of the following form:
<: Entity.FieldGroup.FieldName [| Modifier] :>
I need to find the tags and replace them with some value(s). So for example the text I have might look as follows:
Blah <: Person.Meta.Age :> blah <: PERSON.meTA.Dependants | CommaList :>
and when replaced look like:
Blah 30 blah Harry, Mary, John
Now the issues are that:
- There may be different amounts of whitespace after and before the opening and closing tags (<: and :>)
- Things may be entered in different case Person vs PERSON, Meta vs meTA
- I cannot "affect" the text around the tags
- There is no predetermined list of tag names ie. Tomorrow might bring Animal.Kind for instance
So from a performance point of view what is the best approach here to extract the tags so I can replace them?
I am concerned that as I replace tags the length of the string I am replacing into changes and thus any offsets won't work and so on. Any suggestions on how to achieve the above elegantly?
Aucun commentaire:
Enregistrer un commentaire