http://www.perlmonks.org?node_id=1005036


in reply to Regexp help

First of all, what do you mean by null? I will assume you mean undef, but you might as well mean the numerical value 0.

Secondly, one of Perl's slogan's is There Is More Than One Way To Do It, or TIMTOWTDI as we say. This applies here as well. There is no the correct way, there are many.

My next question, thus, is: what have you tried? Why didn't it work? Did you get any error messages and if you did, which? How did your output not meet your expectations?

Lastly, a regular expression in the traditional sense (m//) might not b the most suitable task. What you have is a | delimited string, so most likely you'll want to split on that. Keep in mind that split takes a regular expression as its first argument, and | has a special meaning inside regular expression so you'll have to escape that.

Then you'll want to iterate over the list you get, using something like map for example, or if you're uncomfortable with those merits of functional programming, you could do it with a simple foreach loop over the array.

This should give you the building blocks you're looking for.

Replies are listed 'Best First'.
Re^2: Regexp help
by hey_frind (Initiate) on Nov 22, 2012 at 18:14 UTC

    Thank you.

    the back ground is I am using regexp in sql (not really perl this time)

    I tried the following:

    REGEXP_SUBSTR({total},'^*', 1, 1) where total is the input string

    I result I am getting is its not recongizing the empty (or null) columns.