0

extractx problem

no experience with regex

Need to use extractx

If anyone can help, would be greatly appreciated!

 

text field = textA - textB

 

would like to put textA into one field and textB into another field (functionfields):

textfield1 = textA

textfield2 = textB

7 replies

null
    • Lars
    • 2 yrs ago
    • Reported - view

    Hi Louis,

    I'm not sure if your text field is something like "wordA - wordB" or "any text with as many spaces as you like - and another text with 4 or more word separated by the minus sign".

    In case of "wordA - wordB", the command you're looking for is:

    textfield1 := extractx('Gerätename', "^\b[A-Za-z]*\b")
    textfield2 := extractx('Gerätename', "\b[A-Za-z]*\b$")
    • NYNNA
    • Louis_Cornacchia
    • 2 yrs ago
    • Reported - view

    "

    "^\b[A-Za-z]*\b" fascinating. Need to learn this, remarkable terse.
    
    Thank you but the problem is "text variable length1" space-hyphen-space "text variable length2"
    
    
    • Lars
    • 2 yrs ago
    • Reported - view

    I feared so ... here's the trick. Just add a " " to the allowed characters

    let mytext := "whatever you want - whatever you like";
    
    let textfield1 := extractx(mytext, "^\b[A-Za-z ]*\b");
    let textfield2 := extractx(mytext, "\b[A-Za-z ]*\b$")
    
    textfield1 + " / " + textfield2

    AND ... if you like to have numbers in the "text variable length1":

    let mytext := "whatever you want - whatever you like";
    
    let textfield1 := extractx(mytext, "^\b[A-Za-z0-9 ]*\b");
    let textfield2 := extractx(mytext, "\b[A-Za-z0-9 ]*\b$")
    
    textfield1 + " / " + textfield2

    And btw, 'Gerätename' was just a field name I had in a test database and which I used ... forget it.

    It you want to know what the stuff means:

    • ^ is the beginning of a text, i.e. for textfield1 I start the search at the beginning
    • [A-Za-z0-9 ] searches for a character from exactly that range
    • * means 0 or more of these characters
    • \b looks for a word boundary, i.e. any non-character, which in your case means the "-"
    • and $ is the end of the string, i.e. textfield2 searches for such a string that ends at the end of the string.
    • NYNNA
    • Louis_Cornacchia
    • 2 yrs ago
    • Reported - view

    Thanks Lars. Will try this now. 

      • NYNNA
      • Louis_Cornacchia
      • 2 yrs ago
      • Reported - view

      Louis Cornacchia  

      Lars, This is not working.
      
      dynamic dropdown field named 'Customer/Associate  Research' contains  "17 - Brian Fortunato , Mountain Surgery Center'
      
      formula field formula = extractx(text('Customer/Associate  Research'), "^\bA-Za-z0-9]*\b")
      The result is empty
      
      • Lars
      • 2 yrs ago
      • Reported - view

      Louis Cornacchia 

      Louis, you forgot the whitespace. But the comma is also something you didn't mention before. So here's a solution that covers your example:

      let mytext := "17 - Brian Fortunato , Mountain Surgery Center";
      
      let textfield1 := extractx(mytext, "^\b[A-Za-z0-9 ,]*\b");
      let textfield2 := extractx(mytext, "\b[A-Za-z0-9 ,]*\b$")
      
      "text field 1 is: '" + textfield1 + "', text field 2 is '" + textfield2 + "'"
      

      Please copy exactly the two lines ... exactly !!!

      My result is

      text field 1 is: '17', text field 2 is 'Brian Fortunato , Mountain Surgery Center'
      
    • NYNNA
    • Louis_Cornacchia
    • 2 yrs ago
    • Reported - view

    Thank you. Much appreciated. 

Content aside

  • Status Answered
  • 2 yrs agoLast active
  • 7Replies
  • 71Views
  • 2 Following