如何仅使用Hive中的regexp_extract函数提取标点符号

时间:2017-08-06 14:28:15

标签: hadoop hive

我正在学习hive中的regexp_extract函数假设我有表' A'用列'字'如,

A word Hello! world, how are you?

我只想提取标点,以便输出

! , ?

如何使用regexp_extract执行此操作我尝试如下但未获得所需的输出,

select regexp_extract(word,"[^A-Za-z0-9]*","1") from A;

请指导!

1 个答案:

答案 0 :(得分:0)

  var nameRegx = /^[' a-zא-ת]+(\s[' a-zא-ת]+)*$/i,
    emailRegx = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})$/,
    phoneRegx = /^(?:0(?!(5|7))(?:2|3|4|8|9))(?:-?\d){7}$|^(0(?=5|7)(?:-?
     \d){9})$/,
    td = 'p.text-danger',
    sa = '#submitAnimate',
    sb = '#submitBtn',
    nf = '#name',
    ef = '#email',
    pf = '#phone',
    mf = '#message';

 $(sa).hide();

 $('#contactForm').on('submit', function (event) {

  event.preventDefault();
 var isValid = true;
 $(td).text('');
 $(' input[type="text"], textarea').removeClass('error');
$(sb).attr('disabled', true);
  $(sa).show();

 var userData = {
name: $(nf).val().trim(),
email: $(ef).val().trim(),
phone: $(pf).val().trim(),
message: $(mf).val().trim()
 };

 if (userData.name.length < 2 || userData.name.length > 70 || 
 !nameRegx.test(userData.name)) {
isValid = false;
  setError(nf, 'name');
  }

  if (!emailRegx.test(userData.email)) {
  isValid = false;
  setError(ef, 'email');
  }

if (!phoneRegx.test(userData.phone)) {
isValid = false;
setError(pf, 'phone');
   }

 if (userData.message.length < 3) {
isValid = false;
setError(mf, 'message');
 }

  if (!isValid) {

$(sb).attr('disabled', false);
setTimeout(function(){ $(sa).hide(); }, 500);

 } else {

  $.ajax({
  url: "assets/contact_form/process-contact.php",
  type: "POST",
  dataType: "html",
  data: userData,
  beforeSend: function () {
    $( sb ).val('Sending...');
  },
  success: function (response) {

    if (response == true) {

    successmessage = 'Data was succesfully captured';
            $("#gmsg").text(successmessage);//THIS MESSAGE DOESN'T APPEAR


    } else {

      $( sb ).val('Can not send, please try latter');

    }
  }
});

  }

});

$('input[type="text"], textarea').on('keyup', function () {
  $(this).next().text('');
});

  function setError(target, field) {
setTimeout(function () {
   $(target).val('').addClass('error');
  $(target).next().text('* Please enter your ' + field);
  }, 500);
   }