<p>If you are using Java or JavaScript, is there a good way to do something like a String subtraction so that given two strings:</p>

<pre><code>org.company.project.component
org.company.project.component.sub_component
</code></pre>

<p>you just get:</p>

<pre><code>sub_component
</code></pre>

<p>I know that I could just write code to walk the string comparing characters, but I was hoping there was a way to do it in a really compact way.  </p>

<p>Another use-case is to find the diff between the strings:</p>

<pre><code>org.company.project.component.diff
org.company.project.component.sub_component
</code></pre>

<p>I actually only want to remove the sections that are identical.</p>

```
```
String result = "org.company.project.component.sub_component".replace("org.company.project.component","")
```
```
Should work...
EDIT: Apache commons libraries are also great to use
As noted below, the StringUtils class does in fact have a method for this:
StringUtils.remove()