Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is a more generic solution that will work with any number of items:</p> <pre><code>Dim sourceString As String = "Domain\X_User|X_User,Domain\Y_User|Y_User," Dim domainsAndUsers As IEnumerable(Of String) = sourceString.Split(","c).Where(Function(s) Not String.IsNullOrEmpty(s)) Dim usersWithoutDomains As IEnumerable(Of String) = domainsAndUsers.Select(Function(s) s.Remove(0, s.IndexOf("\") + 1)) Dim users As IEnumerable(Of String) = usersWithoutDomains.Select(Function(s) s.Remove(s.IndexOf("|"))) Dim result As String = users.Aggregate(Function(s, d) s &amp; "," &amp; d) </code></pre> <p>Or if you want it as a single-line function, here:</p> <pre><code> Function Foo(sourceString As String) As String Return sourceString.Split(","c).Where(Function(s) Not String.IsNullOrEmpty(s)).Select(Function(s) s.Remove(0, s.IndexOf("\") + 1)).Select(Function(s) s.Remove(s.IndexOf("|"))).Aggregate(Function(s, d) s &amp; "," &amp; d) End Function </code></pre> <p>EDIT:</p> <p>You may have to add <code>Imports System.Linq</code> to the top. Not sure if SSRS can use LINQ or not. If not, then here is a similar solution without LINQ:</p> <pre><code>Dim sourceString As String = "Domain\X_User|X_User,Domain\Y_User|Y_User," Dim domainsAndUsers As IEnumerable(Of String) = sourceString.Split(","c) Dim usersWithoutDomains As String = String.Empty For Each domainUser As String In domainsAndUsers usersWithoutDomains &amp;= domainUser.Remove(0, domainUser.IndexOf("\") + 1) &amp; "," Next </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload