Forum Discussion

ArchiveUser's avatar
ArchiveUser
Qrew Captain
10 years ago

Can I extract specific text from the middle of a string?

I have a field that contains serial numbers within blocks of sentence text. I want to extract the serial numbers and place them into their own field. I cannot control the input into these fields or mandate that a new field be filled out.

For example, the field may contain: 

"Picked up S5442 at Boxies on Golden" or "S5931 inbound to home"

What I'd like my formula field to display is "S5442" and "S5931" respectively.

The serial numbers will always start with "S5" and be 5 characters long total.

What would be ideal is something similar to excel's 'Find' formulas - for example: MID(A1, FIND("S5", A1,), 5) - However I can't seem to find anything analogous to this in Quickbase.

20 Replies

  • But the "best" known QuickBsae formula fails on this test case:

    I am driving down US54 to pick up a load of SASSAFRAS AND BOXES OF S5442

    You simply cannot get the anywhere near the level of precision with the extremely limited set of text manipulation functions in QuickBase compared to using script and regular expressions.
  • Thanks a bunch guys - I realize it's not the most elegant solution when compared to script/code, but this is pretty much what I was looking for and it works.
  • B> ...  it's not the most elegant solution ...

    Southbound US54 closed due to overturned truck spilling SASSAFRAS AND BOXES OF S5442, S5443, S5444, S5445, S5446, S5447, S5448, S5449, S5450, S5451, S5452 - Northbound US54 carrying <script> traffic unaffected.
  • Hey Dan,
    You simply cannot get the anywhere near the level of precision with the extremely limited set of text manipulation functions in QuickBase compared to using script and regular expressions

    You mentioned that this could be done with script and regular expressions - can this be done within a quickbase formula field?

    I've noticed that within a text formula field I can include "javascript($string..." and it will accept it, but any parameters of the javascript variable willl error out (ex: javascript($string.search("S5")) will result in an error at the .search part).
    • _anomDiebolt_'s avatar
      _anomDiebolt_
      Qrew Elite
      It isn't worth the trouble trying to put JavaScript into your formulas as you will have a difficult time debugging your formulas and adding a lot of character escaping which makes the formulas unreadable. It is best to get out of the formula language as quickly as possible and pass the least amount of field values to the script. When you try to do parsing like this exclusively in the formula language you have to limit yourself to some upper bound of instances you can parse because the formula language has no looping or iterative methods and this process makes for jumbo formulas. In script you have no such limitations or nuisances.

      Anyways I have a demo in preparation for a similar question which I should finish shortly. I will reread your question and reply further when I get a chance.
    • BobJordan's avatar
      BobJordan
      Qrew Cadet
      Hi,

      Thanks Dan. Understood about the script in formulas - it does seem rather cumbersome. If I wanted to look into getting out of formulas though, where woudl you input the script? 

      I work with imported sheets, so I'm attempting to pull the middle strings out from these imported fields. Is there a specific type of field and format I should use to make use of script?