Jump to content

Substitute % + number


This topic is 4329 days old. Please don't post here. Open a new topic instead.

Recommended Posts

This threw me for a loop.

I have a simple substitute calculation. I want to exchange the HTML %20 in a text string with a space.

I have escaped the "%" with a backslash and that works fine...

but when I substitute "\%20" with " ", the "20" part doesn't substitute. I get the following result:

...something like abcde\%20fghi turns into abcde 20fghi. I want it to become abcde fghi. (If it matters, this is Filemaker Pro 10 Advanced.)

I don't get it. It's a text string. It should treat the numbers the same as any other text shouldn't it and remove them... or am I missing something obvious?

Link to comment
Share on other sites

There is no need to escape anything here:

Substitute ( YourHTML ; "%20"  ; " " )

should work just fine.

something like abcde%20fghi turns into abcde 20fghi.

Well, that's very strange, because using your formula the result should be "abcde%20fghi" (no change from the original). Perhaps there's something you haven't told us about.

---

BTW, a backslash is "\", not "/". But it makes no difference here.

Edited by comment
Link to comment
Share on other sites

Here's the string I passed to the calculation (via a user input box):

text%20moretext

Here's the calculation:

Substitute ( UserInput; "\%20" ; " " )

And here's the result:

text 20moretext

The desired result is: text moretext.

Hmmmm, I thought the % had to be escaped (with a backslash) because the calc wasn't working but I get the same result either way. I still don't understand why the "20" is still in there.

Link to comment
Share on other sites

Something doesn't add up, because this:

Substitute ( "text%20moretext"; "%20" ; " " )

does result in this:

text moretext

Link to comment
Share on other sites

It does for me too.

But when I put it in a script and feed "text%20moretext" into the "Show Custom Dialog" box script step, the space is correctly substituted for the % sign but the "20" is still mysteriously there. Does that Show Custom Dialog input window do something I don't understand?

Just to provide some context... the user will be copying and pasting Firstname%20Lastname from a Web browser into the database.

Link to comment
Share on other sites

But when I put it in a script and feed "text%20moretext" into the "Show Custom Dialog" box script step, the space is correctly substituted for the % sign but the "20" is still mysteriously there.

Mysterious indeed. Could you post a demo file showing this?

Link to comment
Share on other sites

Mysterious indeed. Could you post a demo file showing this? 

That turned out to be more complicated than I expected. There are a lot of dependencies in the calculations in this script. It does many other things, including searching to see if the entry already exists, starting a new one if it doesn't, stripping leading and trailing spaces (separate calculation from the one that is be-deviling me). Everything works great and has been working for some time, except the calc that takes out the % sign but not the number.

I'll try to separate it out and pare it down, but it's not trivial.

Link to comment
Share on other sites

This topic is 4329 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.