Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

Code problem

  • 27-02-2011 06:02PM
    #1
    Registered Users, Registered Users 2 Posts: 1,857 ✭✭✭


    Hey just wondering if someone can tell me the right line of code to use.

    Basically my product codes for an ecommerce site all begin with three letters and an '/' sign

    e.g ABC/1234 would map to the brand ABC in my excell file(product upload mapping)

    This was done as the csv generating from my POS database wasnt generating brand names.

    See line in code it basically says that after the first three letters that are separated with the '/' symbol they will map the brand name right.

    Now we have changed 2 products to contain a '-' symbol instead of '/'

    ABC-1234 instead of ABC/1234.

    I need the right sql code to say anything with a - is added just like the / sign.
     public static string GetBrandNameFromStockref(string StockRef)
            {
                String strb = String.Empty;
                Hashtable brand = new Hashtable();
                brand.Add("ABC", "ABC PRODUCT");
    
     IDictionaryEnumerator iEnum = brand.GetEnumerator();
              [COLOR="Blue"]  string[] fbrand = StockRef.Split('/');[/COLOR]
                while (iEnum.MoveNext())
                {
                    if (iEnum.Key.ToString().ToLower() == fbrand[0].ToLower())
                    {
                        strb = iEnum.Value.ToString();
                        break;
                    }
                }
                if (strb == "")
                    return fbrand[0];
                else
                    return strb;
            }
            public static string GetProductNameFromStockref(string StockRef)
            {
                string[] prdName = StockRef.Split('_');
                return prdName[0];
            }
        }
    }
    
    

    The line in question is this line string[] fbrand = StockRef.Split('/');

    My friend said just need to change the regex string to work for either "/" or "-" but i cant get it working, any ideas?


Comments

Advertisement