asp.net - VB.net .replace start and end of string -


i use dynamically place system variable of url class on body. problem strips first trailing '/' , replaces hyphen, annoying.

how prevent , replace first '/' nothing?

vb

<body class="<%=request.servervariables("url").replace(".aspx","").replace("/","-")%>"> 

at moment if use:

<body class="<%=request.servervariables("url").replace(".aspx","").replace("/","")%>"> 

i 'userprofileedit' url of /user/profile/edit

what want 'user-profile-edit' class on body instead of 'userprofileedit'. first example:

<body class="<%=request.servervariables("url").replace(".aspx","").replace("/","-")%>"> 

does need, starting hyphen due first / '/user..' - hope better explains problem.

you can use substring(1) first character:

<body class="<%=request.servervariables("url").substring(1).replace(".aspx","").replace("/","-")%>"> 

note: approach of using replace remove .aspx page remove folder if happen contain that, long aware of , don't name folders way, you're safe.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -