Skip to content

Prevent replacement of { and } in chat.format#296

Closed
zford wants to merge 1 commit into
essentials:2.9from
zford:chat-braces
Closed

Prevent replacement of { and } in chat.format#296
zford wants to merge 1 commit into
essentials:2.9from
zford:chat-braces

Conversation

@zford
Copy link
Copy Markdown
Contributor

@zford zford commented Feb 4, 2013

This is a refinement of the combination of these two pull requests. It performs the same functionality, but doesn't require gross regex to pull off.

#284
#285

@snowleo
Copy link
Copy Markdown
Member

snowleo commented May 4, 2013

Please explain (?<='[{}]{0,99})([{}])''('*)(?=[{}]') what do you expect it to do

@khobbits
Copy link
Copy Markdown
Member

khobbits commented May 4, 2013

I was thinking something like this instead:

            format = Util.replaceFormat(format);
            format = format.replace("'", "''");
            format = format.replace("{DISPLAYNAME}", "%1$s");
            format = format.replace("{GROUP}", "{0}");
            format = format.replace("{MESSAGE}", "%2$s");
            format = format.replace("{WORLDNAME}", "{1}");
            format = format.replace("{SHORTWORLDNAME}", "{2}");
            format = format.replaceAll("\\{(\\D*?)\\}", "'\\{$1\\}'");
            format = "§r".concat(format);
            mFormat = new MessageFormat(format);

@zford
Copy link
Copy Markdown
Contributor Author

zford commented May 4, 2013

Your code doesn't handle edge case of unmatched braces.

My code produces extra quotes when you have two braces next to each other.

ie

{}} produces '{''}''}' when it should be '{}}'. That regex removes those extra braces.

@zford zford closed this May 4, 2013
@zford zford reopened this May 4, 2013
@khobbits khobbits closed this Jun 25, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants