Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork298
Restricting characters in a quoted string#460
-
I have a double- or single-quoted string like this which works great: I want to restrict the characters in it, so I replaced it with this: This throws an exception on the same input though. I'm guessing I'm missing something subtle. Appreciate any tips on how to accomplish the goal. (Thanks for the wonderful package, Paul!) |
BetaWas this translation helpful?Give feedback.
All reactions
This gave me just enough to go on that I figured out the problem: I wasn't excluding single or double quotes from the word, so my string var was eating them.
This:
quotes: str = "\"'"string: Word = Word(printables, exclude_chars=quotes + meta_chars, min=2)double_quoted_string: ParserElement = Combine(double_quote + string + double_quote)single_quoted_string: ParserElement = Combine(single_quote + string + single_quote)string_def: ParserElement = double_quoted_string | single_quoted_stringis how to replace this and only include printable characters (except quotes and meta characters):
string_def: QuotedString = QuotedString('"', unquote_results=False) | QuotedString( "'", unquote…Replies: 3 comments
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
What is in meta_chars? And what is the input that is failing that you expect to succeed? |
BetaWas this translation helpful?Give feedback.
All reactions
-
If there are spaces in your quoted strings, then the expression you've written won't match them because printables does not include any whitespace characters. |
BetaWas this translation helpful?Give feedback.
All reactions
-
This gave me just enough to go on that I figured out the problem: I wasn't excluding single or double quotes from the word, so my string var was eating them. This: is how to replace this and only include printable characters (except quotes and meta characters): |
BetaWas this translation helpful?Give feedback.