Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

String Manipulation??

Engaged ,
Feb 18, 2009 Feb 18, 2009
Hi,

I am using CF8. I knew how to do this before, but can't recall now.

How I can extract the all the numbers to the left of the "_" (underscore)? The length to the left might be 3 or more

Sample data:

522_1 (in this case, grab just the 522)
92223_5 (in this case, grab just the 92223).

Hope that makes sense.

-Westside
309
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 18, 2009 Feb 18, 2009
WestSide wrote:
> Hi,
>
> I am trying to find out how to loop over a query horizontally in a sense. My
> recordset looks like this:
>
> Column Headers (each number represents a question_id, and the email column is
> the user's email address )
> 1 | 2 | 3 | 4 | 5 | 6 |7 | 8 | 9 | 10 | 11 | 12 | Email
>
> Sample Values
> 3 | 5 | 3 | 5 | 5 | 4 | 3 | 2 | 5 | 5 | 4 | 1 | johndoe@test.com
>
> 4 | 4 | 2 | 4 | 5 | 2 | 1 | 2 | 5 | 3 | 4 | 2 | roger@abccompany.com
>
> --------------
>
> Each row represents multiple answers to multiple questions. So for a given
> row I need to grab the header which is the question_id, then grab the
> associated value and insert it into the database. So I really need to loop
> over each column within the row.

<cfloop from="1" to="#answers.recordCount#" index="i">

<cfloop from="1" to="#ListLen(answers.ColumnList)#" index="j">
QuestionID=#ListGetAt(answers.ColumnList, j)#
Answer=#answers[ListGetAt(answers.ColumnList, j)] #
</cfloop>
</cfloop>

--
Mack
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 18, 2009 Feb 18, 2009
ListFirst
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 18, 2009 Feb 18, 2009
LATEST
<cfset theFirstChunk = ListFirst("522_1","_")>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources