Search code examples
stringjython

Jython Splitting String Up


I am trying to manipulate a string using Jython, I have included below an example string:

This would be a title for a website :: SiteName
This would be a title for a website :: SiteName :: SiteName

How to remove all instances of ":: Sitename" or ":: SiteName :: SiteName"?


Solution

  • No different from regular Python:

    >>> str="This would be a title for a website :: SiteName"
    >>> str.replace(":: SiteName","")
    'This would be a title for a website '
    >>> str="This would be a title for a website :: SiteName :: SiteName"
    >>> str.replace(":: SiteName","")
    'This would be a title for a website '