Q:

Finding WebElement by Link Text that starts-with

I'm trying to find a given link WebElement by partial link text but I want to leverage starts-with to make it more robust.   The WebElement I am trying to find is the second one in the following list ...
<a id="" class="" onmouseout="" href="some.random.href" target="" onmousedown="" onmouseup="" onmouseover="" title="" onclick=""> nsfoobar:80</a>
<a id="" class="" onmouseout="" href="some.other.random.href" target="" onmousedown="" onmouseup="" onmouseover="" title="" onclick=""> sfoobar:443</a>

I thought finding it by xpath and starts-with would be a good approach but it's throwing a NoSuchElementException ...
sfoobarXpath = "//a[starts-with(.,'  sfoobar:')]";
driver.findElement(By.xpath(sfoobarXpath)).click();

Any idea what I'm doing wrong here? 
EDIT1: Edited example to better illustrate problem
EDIT2: I need to be able to find this WebElement without knowledge of the text of the other WebElement; in my actual environment, there can be any number of these link elements and they're subject to change. 

A:

Try this xpath expression:
**//a[normalize-space(substring-before(.,':'))='sfoobar']**

substring-before(.,':')  retrieves the text content of the WebElement before the colon character. 
normalize-space() removes the leading whitespace from the WebElement.