Re: Convert String to Url Format

2009-02-11 Thread Ken Egozi
you can use a regex
say (notepad code):
var cleanedUrl = new Regex([^-a-z0-9],
RegexOptions.IgnoreCase).Replace(url, -);

maybe then I'd add a   new regex(-+).Replace(cleanedUrl, -) to avoid
double '-' characters




On Wed, Feb 11, 2009 at 6:38 PM, eyal ebarda...@gmail.com wrote:


 Hi All,

 I need to convert a string into url compatible format. For example,

 Product cost $24.00  higher/lower.- original string

 product-cost-24-00-higher-lower  - url format

 I know that I can use string.Replace()  but there are alot of
 characters that I may have to replace to accommodate a proper url. Is
 there a function that is already written that I can use?

 thanks

 eyal
 



-- 
Ken Egozi.
http://www.kenegozi.com/blog
http://www.delver.com
http://www.musicglue.com
http://www.castleproject.org
http://www.gotfriends.co.il

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Castle Project Users group.
To post to this group, send email to castle-project-users@googlegroups.com
To unsubscribe from this group, send email to 
castle-project-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~--~~~~--~~--~--~---



Re: Convert String to Url Format

2009-02-11 Thread Patrick Steele

HttpUtility.UrlEncode()

On Wed, Feb 11, 2009 at 11:38 AM, eyal ebarda...@gmail.com wrote:

 Hi All,

 I need to convert a string into url compatible format. For example,

 Product cost $24.00  higher/lower.- original string

 product-cost-24-00-higher-lower  - url format

 I know that I can use string.Replace()  but there are alot of
 characters that I may have to replace to accommodate a proper url. Is
 there a function that is already written that I can use?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Castle Project Users group.
To post to this group, send email to castle-project-users@googlegroups.com
To unsubscribe from this group, send email to 
castle-project-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~--~~~~--~~--~--~---



Re: Convert String to Url Format

2009-02-11 Thread eyal

Thank you all for the quick reply. Ken your suggestion works like a
charm.

On Feb 11, 8:53 am, Ken Egozi egoz...@gmail.com wrote:
 you can use a regex
 say (notepad code):
 var cleanedUrl = new Regex([^-a-z0-9],
 RegexOptions.IgnoreCase).Replace(url, -);

 maybe then I'd add a   new regex(-+).Replace(cleanedUrl, -) to avoid
 double '-' characters



 On Wed, Feb 11, 2009 at 6:38 PM, eyal ebarda...@gmail.com wrote:

  Hi All,

  I need to convert a string into url compatible format. For example,

  Product cost $24.00  higher/lower.    - original string

  product-cost-24-00-higher-lower          - url format

  I know that I can use string.Replace()  but there are alot of
  characters that I may have to replace to accommodate a proper url. Is
  there a function that is already written that I can use?

  thanks

  eyal

 --
 Ken 
 Egozi.http://www.kenegozi.com/bloghttp://www.delver.comhttp://www.musicglue.comhttp://www.castleproject.orghttp://www.gotfriends.co.il
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Castle Project Users group.
To post to this group, send email to castle-project-users@googlegroups.com
To unsubscribe from this group, send email to 
castle-project-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~--~~~~--~~--~--~---



Re: Convert String to Url Format

2009-02-11 Thread eyal

Hi Alex,

RegexReplace is not recognized to be a valid method. Am I missing a
lib ref? (Regex is recognized)

thanks
eyal

On Feb 11, 10:55 am, Alex Henderson bitterco...@gmail.com wrote:
 I have an extension method I use for this, basically the same as Kens...

     public static string Slugify(this string text)
     {
       return text.ToLowerInvariant().RegexReplace([^a-z0-9]+,
 -).RegexReplace(-+$, ).RegexReplace(^-+$, );
     }

 On Thu, Feb 12, 2009 at 5:38 AM, eyal ebarda...@gmail.com wrote:

  Hi All,

  I need to convert a string into url compatible format. For example,

  Product cost $24.00  higher/lower.    - original string

  product-cost-24-00-higher-lower          - url format

  I know that I can use string.Replace()  but there are alot of
  characters that I may have to replace to accommodate a proper url. Is
  there a function that is already written that I can use?

  thanks

  eyal
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Castle Project Users group.
To post to this group, send email to castle-project-users@googlegroups.com
To unsubscribe from this group, send email to 
castle-project-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~--~~~~--~~--~--~---



Re: Convert String to Url Format

2009-02-11 Thread eyal

Also please explain if there is an advantage over Ken's method

On Feb 11, 10:55 am, Alex Henderson bitterco...@gmail.com wrote:
 I have an extension method I use for this, basically the same as Kens...

     public static string Slugify(this string text)
     {
       return text.ToLowerInvariant().RegexReplace([^a-z0-9]+,
 -).RegexReplace(-+$, ).RegexReplace(^-+$, );
     }

 On Thu, Feb 12, 2009 at 5:38 AM, eyal ebarda...@gmail.com wrote:

  Hi All,

  I need to convert a string into url compatible format. For example,

  Product cost $24.00  higher/lower.    - original string

  product-cost-24-00-higher-lower          - url format

  I know that I can use string.Replace()  but there are alot of
  characters that I may have to replace to accommodate a proper url. Is
  there a function that is already written that I can use?

  thanks

  eyal
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Castle Project Users group.
To post to this group, send email to castle-project-users@googlegroups.com
To unsubscribe from this group, send email to 
castle-project-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~--~~~~--~~--~--~---



Re: Convert String to Url Format

2009-02-11 Thread Alex Henderson
I have an extension method I use for this, basically the same as Kens...

public static string Slugify(this string text)
{
  return text.ToLowerInvariant().RegexReplace([^a-z0-9]+,
-).RegexReplace(-+$, ).RegexReplace(^-+$, );
}

On Thu, Feb 12, 2009 at 5:38 AM, eyal ebarda...@gmail.com wrote:


 Hi All,

 I need to convert a string into url compatible format. For example,

 Product cost $24.00  higher/lower.- original string

 product-cost-24-00-higher-lower  - url format

 I know that I can use string.Replace()  but there are alot of
 characters that I may have to replace to accommodate a proper url. Is
 there a function that is already written that I can use?

 thanks

 eyal
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Castle Project Users group.
To post to this group, send email to castle-project-users@googlegroups.com
To unsubscribe from this group, send email to 
castle-project-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~--~~~~--~~--~--~---



Re: Convert String to Url Format

2009-02-11 Thread Alex Henderson
Sorry, regex replace is another extension method..

public static string RegexReplace(this string input, string pattern,
string replace)
{
  return Regex.Replace(input, pattern, replace);
}

No advantage over kens implementation I could see, just adding some weight
to the fact that his approach works in the wild :)

On Thu, Feb 12, 2009 at 8:12 AM, eyal ebarda...@gmail.com wrote:


 Also please explain if there is an advantage over Ken's method

 On Feb 11, 10:55 am, Alex Henderson bitterco...@gmail.com wrote:
  I have an extension method I use for this, basically the same as Kens...
 
  public static string Slugify(this string text)
  {
return text.ToLowerInvariant().RegexReplace([^a-z0-9]+,
  -).RegexReplace(-+$, ).RegexReplace(^-+$, );
  }
 
  On Thu, Feb 12, 2009 at 5:38 AM, eyal ebarda...@gmail.com wrote:
 
   Hi All,
 
   I need to convert a string into url compatible format. For example,
 
   Product cost $24.00  higher/lower.- original string
 
   product-cost-24-00-higher-lower  - url format
 
   I know that I can use string.Replace()  but there are alot of
   characters that I may have to replace to accommodate a proper url. Is
   there a function that is already written that I can use?
 
   thanks
 
   eyal
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Castle Project Users group.
To post to this group, send email to castle-project-users@googlegroups.com
To unsubscribe from this group, send email to 
castle-project-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~--~~~~--~~--~--~---



Re: Convert String to Url Format

2009-02-11 Thread Ken Egozi
I bet that RegexReplace  is a simple extension method

On Wed, Feb 11, 2009 at 9:12 PM, eyal ebarda...@gmail.com wrote:


 Also please explain if there is an advantage over Ken's method

 On Feb 11, 10:55 am, Alex Henderson bitterco...@gmail.com wrote:
  I have an extension method I use for this, basically the same as Kens...
 
  public static string Slugify(this string text)
  {
return text.ToLowerInvariant().RegexReplace([^a-z0-9]+,
  -).RegexReplace(-+$, ).RegexReplace(^-+$, );
  }
 
  On Thu, Feb 12, 2009 at 5:38 AM, eyal ebarda...@gmail.com wrote:
 
   Hi All,
 
   I need to convert a string into url compatible format. For example,
 
   Product cost $24.00  higher/lower.- original string
 
   product-cost-24-00-higher-lower  - url format
 
   I know that I can use string.Replace()  but there are alot of
   characters that I may have to replace to accommodate a proper url. Is
   there a function that is already written that I can use?
 
   thanks
 
   eyal
 



-- 
Ken Egozi.
http://www.kenegozi.com/blog
http://www.delver.com
http://www.musicglue.com
http://www.castleproject.org
http://www.gotfriends.co.il

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Castle Project Users group.
To post to this group, send email to castle-project-users@googlegroups.com
To unsubscribe from this group, send email to 
castle-project-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~--~~~~--~~--~--~---