Views output realname field as a contextual link Contextual is set up to display all content from a user for a specific content type.
www.example.com/users/realname/gallery where realname is contextual filter.
Realname is used with token that reflects field from registration: field-choose-realname.

Lets say we have 2 users and 1st writes "One" as realname and 2nd writes "One Two".
Realname contextual filter is setup to use lowercase and change spaces to dash.

Here is what happens:
www.example.com/users/one/gallery - ok  

www.example.com/users/one-two/gallery - page not found error
www.example.com/users/one%20two/gallery - ok  

For Contextual "when the filter is in the URL or a default is provided" i am using this php code (i did not write it so i have no clue what it does really):  

if (!isset($argument)) {
  return FALSE;
}
$query = db_query('SELECT uid, realname FROM {realname} WHERE realname = :realname', array(':realname' =&gt; $argument));
$row = $query-&gt;fetchAssoc();
if (isset($row['uid'])) {
  return TRUE;
}
return FALSE;


To better explain what i want to do:
Get sidebar menu like on myspace for bands. When you land on bands page you can use sidebar menu to check their foto galleries, band members, video gallery and links must be made with a field that is not default username (it can be realname module or some other text field). Field validation is used so i do not get same name twice, and all links in pathauto are made example.com/bands/realname.
To repeat again it does work if realname contains 1 word.
Setting the contextual filter to transform spaces to dashes will not make the Realname field in the database contain dashes, so the filter fails. In your url you look for one-two, in the database this is One Two they are not the same and it doesn't work (one-two ≠ One Two).

First make sure pathauto is installed and enabled. It will provide your users with a pretty url. This will make sure every user has a unique path. 
If you replace spaces and dashes in the URL as you do now, the contextual filter for these users One Two, One-Two, One'Two will all become one-two even if they are if fact different users. So your results will be mixed up. Pathauto will make sure they become unique; one-two, one-two2 and so on. 

Do not rely on simple pattern matching, but use the uid from the instead. Luckily we can hide this entirely from the url by using a View's contextual filter.

Update

It seems I have missed a module requirement; Sub-pathauto (Sub-path URL Aliases).


  The Drupal Path module matches only full URLs when creating
  SEO-friendly aliases. This module extends that behavior by also
  matching known sub-paths and replacing them with their respective
  alias.
  
  For example, if user/1 is aliased to users/admin, this module rewrites
  the link to the user contact page user/1/contact to use the aliased
  URL users/admin/contact instead.


The is required to properly obtain the UID from the url.

Then create your view as follows:


Use must use the unaliased path for the path. So if your user is at /users/url-safe-realname and your gallery at /users/url-safe-realname/gallery, you enter /user/%/gallery (omit the s in users pathauto adds if using default settings).

For the contextual filter, in the WHEN THE FILTER VALUE IS IN THE URL OR A DEFAULT IS PROVIDED section, check Specify validation criteria, choose user and numeric UIDs.

The result will be a page that has the url-safe realname in the path and shows only content created by the user: