0

regex \, @substitute \\,
The substitution works with the double backslashes, but I can't match the comma. I want an input string

It's not raining, but it will, I'm told.

to look like this

It's not raining\, but it will\, I'm told.

after regex processing

Thank you for your help. John Chowning jc@ccrma.stanford.edu

  • The problem is that messages with commas are interpreted as multiple messages, separated by commas. You can see that if you connect the message box with commas to a print, you will see multiple messages in the Max window. So the question is probably where the message with commas comes from. If possible, you can use a tosymbol object to process the string and keep the commas intact. – Mattijs Aug 09 '20 at 10:12

1 Answers1

1

These are two different methods you can use.


Using the following arguments with the regexp object:

[regexp \\, @substitute \\\\,] will yield the correct string to the Max Console

However as a message, a space character will be added. See image: example using the regexp object


Using atoi with regexp to preserve your intended formatting when sending as a message:

  • By converting the string to integers using [atoi] we can perform regex on the ascii decimals 44 and replace them with 92 44 ie: \,
  • The regexp object adds a space character layering another regexp object to replace "32 92" in the string with 92 solves this.

See image: example using atoi and regexp


Patch attached:

<pre><code>
----------begin_max5_patcher----------
1298.3ocyZszaiaCD9r8uBBcYu3FPQQIQ0doONs.s25s0EAzVLILURzPjJO5
h8+dGQIk0OnikroSq.br0HZNb9373anyWmOKXk5EgN.8inuflM6qymMyJpUv
r96mETxeYcAWaGVvZUYonxDrn6YFwKFq7em+pnVVcOx7rBUKtW7xF3sR0SBM
x7f.soVrVHxaGgdCes.DxM1mbmrVaP77b8vjVHqDqUMU1Yl1KDl.MnXtQppt
cmQjzOhUMqVUH1njchw2f6ePUSorpPXrVP3v7wMqe.VN2BKLSGBjjvtglAWL
RXHKAmDmt.EEm0ILgQwYwQLBHLDyfYGkB5.8W6ndsLWX0920spwLnb7Vv1iM
Zi7N4ZqEs8Jqah1VhL2hwpUO9CYYAsx9174s+YwH20pDOCe4C1z52mVFDQPY
jkAneV2rBVUlFi.j1JJXhXXLNxAFRbggIjVLjrMFtKZE2KsSj40MhNc.Kp8d
81DrMRw7HRUn34q3U2OU3HKI7P3fho2jsObDGcBzH7Xngcc4DARNGDnTn076
EG.A+zxZXbH30yxpb0yNiVItvGxTwGB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