saiyan101
saiyan101

Reputation: 620

Remove chars in a string Django python

When I post a value from my page an extra string is create and I would like to remove the 'pattern = "' is there a tag i could use or replace function i can use to remove pattern =" and the ending ". Please find below scenario:

pattern = "apple"

Desired output

apple

I tried using but to no success.Is there another method i could use newbie at django python.

{{ pattern|split }}

Upvotes: 1

Views: 313

Answers (2)

user1752458
user1752458

Reputation:

If the quotation marks are added to your string when you are submitting the form, you could use the .strip() method when accessing the POST data. You can also specify what characters you want to remove. Check it out here: http://docs.python.org/2/library/stdtypes.html

Upvotes: 0

Hedde van der Heide
Hedde van der Heide

Reputation: 22449

Write a custom templatetag and use a regular expression (a capture group would do the trick) to replace the desired part.

Upvotes: 1

Related Questions