Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8343847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:11:24+00:00 2026-06-09T06:11:24+00:00

I have a set of coordinates exported from google sketchup with extra fluff that

  • 0

I have a set of coordinates exported from google sketchup with extra fluff that I’ve been trying to strip with regex. I think it’s really interesting for quickly getting drawings in 3D from e.g. SketchUp into canvas from and .xsi file. The are multiple instances of data sets in one variable:

$str = 'SI_NurbsCurve Edge1 {
        1,
        0,
        0,
        4,
        0,0,1,1,
        2,
        870.243,1229.35,143.395,1
        927.537,1323.53,103.842,1
        }

        SI_NurbsCurve Edge2 {
        1,
        0,
        0,
        4,
        0,0,1,1,
        2,
        899.54,1217.88,116.255,1
        870.243,1229.35,143.395,1
        }';

I’ve attempted to remove everything from the multiple instances except the coordinate data with this regex:

$reg = '#SI_NurbsCurve Edge[^"]* {
        1,
        0,
        0,
        4,
        0,0,1,1,
        2,#';  
$rep=""; 
$str=preg_replace($reg,$rep,$str);

However, this result in only echoing the last coordinate set found in the string, in this example the following remains:

899.54,1217.88,116.255,1
870.243,1229.35,143.395,1

Besides that I’m trying to strip the last number “1” that occurs on each line of coordinates, so this entire example would end up looking like this:

870.243,1229.35,143.395,
927.537,1323.53,103.842,

899.54,1217.88,116.255,
870.243,1229.35,143.395,

I would be very grateful for your time and know-how!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T06:11:26+00:00Added an answer on June 9, 2026 at 6:11 am

    Your first problem (getting only the last values) is probably caused by this:

    #SI_NurbsCurve Edge[^"]*
    

    You would need a non-greedy regex or if the value after Edge are just numbers:

    #SI_NurbsCurve Edge[0-9]*
    

    After that, you can chop of the last two characters of every remaining line.

    You probably need to escape the { character as well: \{ and account for the } and spaces / new-lines after every set so the first line should be something like:

    $str = '#(\}\s+)?SI_NurbsCurve Edge[0-9]* \{
    

    See the working example (except for the last 2 chars of every line…) on Codepad.

    To also get rid of the remaining ,1 at the end of each line, you can change the preg_replace line with:

    $str=preg_replace(array($reg, '#,1\r#'),array($rep,"\r"),$str);
    

    This works on Codepad at least but probably depends on the encoding of the newlines.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to import a set of coordinates from an external javascript. I have
Say we have a set of 3D (integer) coordinates from (0,0,0) to (100,100,100) We
I have a set of coordinates in a database that I want to be
I have a set of (x,y) coordinates that describe the trajectory of an object.
I have a set of x,y map coordinates that I want plotted on an
I'm using the Google Maps Javascript API and I have LatLng coordinates that are
I am trying to fit a transformation from one set of coordinates to another.
How can I input a set of coordinates and have Google maps show a
Assuming I have a large set of Coordinates such us (3,4) , (5,-6) ,
I have set the eclipse java formatter to wrap lines that exceed 120 characters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.